About Author:
Parag Parikh is an SAP ABAP/FS-CD/Workflow consultant with 5.5 years experience. He has worked on multiple SAP modules. He is currently working as workflow expert with Deloitte Consulting LLP.
Summary:
The various credit card companies which import credit card transaction data into Travel Management must convert their format to SAP's internal format. These converted files might not include the employee's personnel number (PERNR) although this field is mandatory in order to perform the actual credit card clearing import. This enhancement enables customers to include coding to automatically retrieve the personnel number from a specified location for inclusion in the import process.
The standard SAP transaction PRCC assigns the transactions in Credit card file to employee on the basis of employee PERNR in the file. In some scenarios the credit card companies might not have the employee PERNR information and will have only the credit card information. So to correctly assign these transactions to employees, PERNRs needs to be included in the file. This development which is through (BAdI-FITV_CCC_M_LINE) will include the PERNRs in the file, when this data is absent.
Code snippet:
Below is the code for implementation of the method CHANGE_CCC_M_LINE of the BAdi interface. Note that this BAdi method is called for each line in the credit card file. Depending on configuration, credit card data stored in infotype PA0105 can me masked or unmasked. We need to use appropriate encryption/decryption to get masked/unmasked credit card number before we select PERNR based on credit card number.
*-- Initial Checks
CHECK receipt-pernr IS INITIAL. " personnel number
*----------------------------------------------------------------------*
* DATA DECLARATION *
*----------------------------------------------------------------------*
DATA:ls_pa0105 TYPE pa0105, "PA0105 Structure
ls_p0105 TYPE p0105, "P0105 Structure
lt_p0105 TYPE STANDARD TABLE OF p0105, "P0105 table.
lt_pa0105 TYPE STANDARD TABLE OF pa0105, "PA0105 Table
lv_ccnum TYPE ptrv_cccmain-cardnum, "Credit Card Number
lv_effdate TYPE ptrv_cccmain-umsdatum, "Effective Date
lv_ccnum_unmasked TYPE ccnum, "Unmasked cc
lv_ccnum_masked TYPE ccnum , "Masked card number
lv_ccnum1 TYPE ccnum ,
lv_cdtype TYPE ccheader-cardcomp, "Credit Card Type
lv_pernr TYPE pa0105-pernr. "PERNR
*----------------------------------------------------------------------*
* CONSTANTS *
*----------------------------------------------------------------------*
CONSTANTS: lc_usrty(4) TYPE c VALUE '0011'. "Subtype
CLEAR:lv_ccnum,lv_effdate,lv_cdtype,lv_ccnum1.
*-- Get data from interface.
lv_ccnum = receipt-cardnum.
lv_effdate = receipt-umsdatum.
lv_cdtype = head-cardcomp.
CONCATENATE lv_cdtype lv_ccnum INTO lv_ccnum1.
lv_ccnum_unmasked = lv_ccnum1.
*-- Use select instead of HR_INFOTYPE operation to avoid masking/encryption
* Use SELECT ENDSELECT loop as per standard SAP BAdi code
SELECT * FROM pa0105
INTO ls_pa0105
WHERE usrty = lc_usrty
AND usrid = lv_ccnum1.
IF sy-subrc = 0.
IF lv_effdate GE ls_pa0105-begda AND lv_effdate LE ls_pa0105-endda.
lv_pernr = ls_pa0105-pernr.
receipt-pernr = lv_pernr.
ENDIF.
ENDIF.
ENDSELECT.
IF sy-subrc = 0.
EXIT.
ENDIF.
*--Check if any record was not found, there is a possibility that card
* is masked. Check using masked number
CLEAR:lv_ccnum1,lv_ccnum_masked.
lv_ccnum1 = lv_ccnum.
CALL FUNCTION 'CCSEC_CCNUM_MASKING'
EXPORTING
i_ccnum = lv_ccnum1
IMPORTING
e_ccnum_masked = lv_ccnum_masked.
CLEAR lv_ccnum1.
CONCATENATE lv_cdtype lv_ccnum_masked INTO lv_ccnum1.
SELECT * FROM pa0105
INTO TABLE lt_pa0105
WHERE usrty = lc_usrty
AND usrid = lv_ccnum1
AND begda LE lv_effdate
AND endda GE lv_effdate.
CHECK lt_pa0105[] IS NOT INITIAL.
LOOP AT lt_pa0105 INTO ls_pa0105.
MOVE-CORRESPONDING ls_pa0105 TO ls_p0105.
APPEND ls_p0105 TO lt_p0105.
CLEAR : ls_p0105 , ls_p0105.
ENDLOOP.
CALL FUNCTION 'CCSECP_IT0105_DECRYPTION'
TABLES
t0105 = lt_p0105.
CLEAR ls_p0105.
READ TABLE lt_p0105 INTO ls_p0105 WITH KEY usrid = lv_ccnum_unmasked.
IF sy-subrc = 0.
lv_pernr = ls_p0105-pernr.
receipt-pernr = lv_pernr.
ENDIF.
CLEAR: lv_pernr, lv_ccnum.
Note:
1) The employee should have credit card information maintained in infotype PA0105.
2) Generally one corporate credit card is allocated to one employee only. In rare scenarios ( although never heared of one ) if the company's policy allows multiple employees to use same credit card, then we need appropriate business logic to identify against which employee, the subsequent clearing of claims should be noted.