10-27-2011 12:39 PM
Hi Experts,
Please help explain the diffrence and usage of methods PRELP_TO_Pnnnn and Pnnnn_TO_PRELP in cl_hr_pnnnn_type_cast . How these methods can be used and where for PAI and PBO part.
Thanks in advance.
Mann
10-27-2011 1:05 PM
Hi,
these method are used when you get the data from IDOC.
The IDOC data is first converted into infotype format using the first method and again in IDOC format using second method.
method cl_hr_pnnnn_type_cast=>prelp_to_pnnnn to convert format of INNN to format of your infotype.
Example:
CALL METHOD cl_hr_pnnnn_type_cast=>prelp_to_pnnnn
EXPORTING
prelp = innnn
IMPORTING
pnnnn = w_0000.
Where w_0000 has type p0000
thanks & regards.
10-27-2011 1:15 PM
Actually this methods are really usefull when using BADI's or USER-EXITS in HR Infotype operations, as all these methods receive generic structures/tables typed with PRELP which is the generic type for all infotypes
When accesing this methods for an specific one, you need to convert this generic structure PRELP into one specifc infotype structure P0009 (for instance), so you can access the specific fields for that infotype. That's when we use PRELP_TO_PNNNN method.
If we make some changes in that structure we probably need to send the changes back to the control program, so we need to embed this specific structure into the original one, in this scenario we use PNNNN_TO_PRELP.
Here's an example with ZXPADU01
case innnn-infty.
when '0002'.
data: l_p0002 type p0002.
call method cl_hr_pnnnn_type_cast=>prelp_to_pnnnn
exporting
prelp = p_innnn
importing
pnnnn = l_p0002.
if l_p0002-natio is initial.
l_p0002-natio = 'ES'.
endif.
if l_p0002-gblnd is initial.
l_p0002-gblnd = 'ES'.
endif.
call method cl_hr_pnnnn_type_cast=>pnnnn_to_prelp
exporting
pnnnn = l_p0002
importing
prelp = p_innnn.
endcase.