Saturday, April 19, 2014

Class CL_HR_PNNNN_TYPE_CAST is used to convert of Pnnnn structures into PRELP or WPLOG tables and vice versa.
This class uses the typing of Pnnnn parameters to carry out the conversion. It is therefore important that these parameters support the desired structure. The methods always use a Pnnnn structure and never a PAnnnn structure.

CL_HR_PNNNN_TYPE_CAST=>PRELP_TO_PNNNN

Method PRELP_TO_PNNNN is used to convert PRELP According to Pnnnn.
PRELP is general structure for all infotypes.
Example: When we implement BADI HRPAD00INFTY(Update / Infotype maintenance), method AFTER_INPUT has two importing structures NEW_INNNN (type PRELP) and OLD_INNNN (type PRELP). If you want to check IT0002-GBLND field, PRELP structure has to be converted into NNNN.
METHOD if_ex_hrpad00infty~after_input.
  DATA:ls_p0002_new TYPE p0002.
  DATA:ls_p0002_old TYPE p0002.

  CALL METHOD cl_hr_pnnnn_type_cast=>prelp_to_pnnnn
    EXPORTING
      prelp = new_innnn
    IMPORTING
      pnnnn = ls_p0002_new.

  CALL METHOD cl_hr_pnnnn_type_cast=>prelp_to_pnnnn
    EXPORTING
      prelp = old_innnn
    IMPORTING
      pnnnn = ls_p0002_old.
  IF ls_p0002_new-gblnd NE ls_p0002_old-gblnd.
    MESSAGE 'Why are you changing Country of birth' TYPE 'I'.
  ENDIF.

ENDMETHOD.

CL_HR_PNNNN_TYPE_CAST=>PRELP_TO_PNNNN_TAB

The method PRELP_TO_PNNNN_TAB is used to convert PRELP According to Pnnnn for Tables.

CL_HR_PNNNN_TYPE_CAST=>PNNNN_TO_PRELP

The method PNNNN_TO_PRELP is used to convert Pnnnn According to PRELP.
Example: Enhancement PBAS0001(SMOD) has two function module exits.(1) EXIT_SAPFP50M_001(Customer Default Values for Personnel Administration and Recruitment).
CASE INNNN-INFTY.
    DATA: LS_P0002   TYPE P0002.

  WHEN '0002'.
    CALL METHOD CL_HR_PNNNN_TYPE_CAST=>PRELP_TO_PNNNN
      EXPORTING
        PRELP = P_INNNN
      IMPORTING
        PNNNN = LS_P0002.

    IF LS_P0002-NATIO IS INITIAL.
      LS_P0002-NATIO = 'ES'.
    ENDIF.

    IF LS_P0002-GBLND IS INITIAL.
      LS_P0002-GBLND = 'ES'.
    ENDIF.

    CALL METHOD CL_HR_PNNNN_TYPE_CAST=>PNNNN_TO_PRELP
      EXPORTING
        PNNNN = LS_P0002
      IMPORTING
        PRELP = P_INNNN.

ENDCASE.

CL_HR_PNNNN_TYPE_CAST=>PNNNN_TO_PRELP_TAB

The method PNNNN_TO_PRELP_TAB is used to convert Pnnnn acccording to PRELP for Tables.

0 comments:

Post a Comment

Your useful comments, suggestions are appreciated.Your comments are moderated.

Followers

Contact Form

Name

Email *

Message *

Web Dynpro ABAP Book

An SAP Consultant

Follow US


Want to Contribute ?

If you are interested in writing about the new stuff you learn everyday while working, please write to the.sap.consultants@gmail.com.

Click on Contribution for more details.