Passing custom field values to the accounting document during GR/Invoice posting.
Step 1: Create an FM with parameters and table structures similar to the example below.
Step 2: Implement the code as shown below and active.
DATA: l_f_ebeln TYPE ebeln.
READ TABLE t_accit INTO DATA(lr_accit) INDEX 1.
IF sy-subrc = 0.
l_f_ebeln = lr_accit-ebeln.
ENDIF.
IF l_f_ebeln IS NOT INITIAL.
SELECT ebeln,ebelp,zz_prd_code,zz_veh_type
FROM ekpo INTO TABLE
@DATA(lt_ekpo)
WHERE ebeln EQ @l_f_ebeln.
ENDIF.
IF lt_ekpo IS NOT INITIAL.
LOOP AT t_accit INTO DATA(lr_accit1) WHERE koart = 'S'.
READ TABLE lt_ekpo INTO DATA(lr_ekpo) WITH KEY ebelp = lr_accit1-ebelp.
IF sy-subrc = 0.
lr_accit1-xref1 = 'XREF1_TEST'.
lr_accit1-xref2 = 'XREF2_TEST'.
lr_accit1-xref3 = 'XREF3_TEST'.
MODIFY t_accit FROM lr_accit1 TRANSPORTING xref1 xref2 xref3 .
ENDIF.
ENDLOOP.
ENDIF.
Step 3: First, we need to identify the relevant FM. Once we find it, we can enhance it and add our custom logic there.
FM: FMRE_FI_BELEG_CHECK
- Go to SE37, enter the FM name
FMRE_FI_BELEG_CHECK, and click Display. - Go to Edit → Enhancement Operations → Show Implicit Enhancement Options.
- Place the cursor on the Implicit Enhancement option and click the Enhance button.
- Right-click → Enhancement Operation → Create Implementation → Code.
- Click Create Implementation, then provide the Implementation Name and Short Text.
- Click Pattern and enter the FM name.
- Please find the screenshot below for reference.
- Check and activate.
Testing: I am posting GR
******************************Thank you*******************************
Comments
Post a Comment