Skip to Content
0
Jul 16, 2020 at 08:43 PM

Table is not updating after Bapi_requirement_change

325 Views

Hello experts,

I am new to ABAP development, I have a requirement where I have to change the requirement date in MD61 with a help of a report. In my selection screen I will have my material number(s), plant and days I want to add to the existing date. I have created the below report where the bapi is getting populated but once I execute it the table is not getting updated with the new data. I am not sure what is causing the issue, in the return table I am not getting any error message, so I can assume the bapi is executed successfully. Can you please suggest what am I doing wrong or how should I commit the changes?

Code Snippet:

TABLES: MARC,pbim,pbed.

DATA: GT_GRID TYPE REF TO CL_GUI_ALV_GRID,
GT_CONT TYPE REF TO CL_GUI_CUSTOM_CONTAINER.

DATA: GT_FCAT TYPE STANDARD TABLE OF LVC_S_FCAT,
WA_FCAT TYPE LVC_S_FCAT.

DATA: OK_CODE TYPE SY-UCOMM.

TYPES: BEGIN OF GS_TAB,
MATNR TYPE MATNR,
WERKS TYPE WERKS_D,
BDZEI TYPE BDZEI,
BEDAE TYPE BEDAE,
VERSB TYPE VERSB,
PBDNR TYPE PBDNR,
PDATU TYPE PDATU,
END OF GS_TAB.


DATA: GT_TAB TYPE STANDARD TABLE OF GS_TAB,
GV_TAB TYPE GS_TAB.

FIELD-SYMBOLS: <FS_TAB> TYPE GS_TAB.

DATA: LT_RETURN TYPE TABLE OF BAPIRETURN1,
LT_REQ_CHANGE TYPE TABLE OF BAPISSHDIN.

DATA: LS_REQ_CHANGE TYPE BAPISSHDIN.

DATA: gv_newdate TYPE EDATU.

*CONSTANTS: abap_true TYPE abap_bool VALUE 'X'.

SELECTION-SCREEN BEGIN OF BLOCK block.
PARAMETER: P_WERKS TYPE MARC-WERKS.
SELECT-OPTIONS: S_MATNR FOR MARC-MATNR.
PARAMETER: P_DAYS TYPE I.
SELECTION-SCREEN END OF BLOCK block.

START-OF-SELECTION.

SELECT A~MATNR
A~WERKS
A~BDZEI
A~BEDAE
A~VERSB
A~PBDNR
B~PDATU
FROM pbim AS A
INNER JOIN pbed AS B
ON A~BDZEI = B~BDZEI
INTO CORRESPONDING FIELDS OF TABLE GT_TAB
WHERE A~WERKS = P_WERKS AND
A~MATNR IN S_MATNR.

*BREAK-POINT.

LOOP AT GT_TAB ASSIGNING <FS_TAB>.
READ TABLE GT_TAB into <FS_TAB> INDEX <FS_TAB>-PDATU.
gv_newdate = <FS_TAB>-PDATU + p_DAYS.

LS_REQ_CHANGE-DATE_TYPE = '1'.
LS_REQ_CHANGE-REQ_DATE = gv_newdate.
APPEND LS_REQ_CHANGE to LT_REQ_CHANGE.

CALL FUNCTION 'BAPI_REQUIREMENTS_CHANGE'
EXPORTING
MATERIAL = <FS_TAB>-MATNR
PLANT = <FS_TAB>-WERKS
REQUIREMENTSTYPE = <FS_TAB>-BEDAE
VERSION = <FS_TAB>-VERSB
REQMTSPLANNUMBER = <FS_TAB>-PBDNR
VERS_ACTIV = 'X'
* REQUIREMENT_PARAM =
* MRP_AREA =
DO_COMMIT = 'X'
UPDATE_MODE = 'X'
DELETE_OLD = ' '
** NO_WITHDR = ' '
* MATERIAL_EVG =
* IMPORTING
* REQUIREMENT_ITEM_OUT =
TABLES
REQUIREMENTS_SCHEDULE_IN = lt_req_change
RETURN = lt_return.
*BREAK-POINT.

if lt_return is INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
*
ENDIF.
ENDLOOP.
CALL SCREEN 100.
INCLUDE ZSARBOSE_REFERENCE_PBO.

INCLUDE ZSARBOSE_REFERENCE_PAI.

INCLUDE ZSARBOSE_REFERENCE_FIELDCATF01.

Your inputs will be highly appreciated.

Thanks,

Sarnava