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

  1. Go to SE37, enter the FM name FMRE_FI_BELEG_CHECK, and click Display.
  2. Go to Edit → Enhancement Operations → Show Implicit Enhancement Options.
  3. Place the cursor on the Implicit Enhancement option and click the Enhance button.
  4. Right-click → Enhancement Operation → Create Implementation → Code.
  5. Click Create Implementation, then provide the Implementation Name and Short Text.
  6. Click Pattern and enter the FM name.
  7. Please find the screenshot below for reference.
  8. Check and activate.

Testing: I am posting GR

  1. Create a new PO or use an existing PO.
  2. Execute T-code MIGO, enter the PO number, and select Movement Type 101.
  3. Fill in all the required details and select the Item OK checkbox.
  4. Click Check to validate the document, then click Post to post the Goods Receipt.
  5. Goto PO screen and select purchase history tab. Click on GR.
  6. Goto doc info and click on fi documents. double click on account on accounting document.

******************************Thank you*******************************

Comments

Popular posts from this blog

Custom entity/Action dialog in RAP using Unmanaged scenario

New syntax for append- VALUE (new syntax 7.4+) in ABAP

Read statement new syntax in ABAP. (7.4+).