Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to update data using BAPI for MD61

Former Member
0 Kudos

Hello,

IN my zprogram i used to bapis for uploading data from flat file to sap-system

1)BAPI_requirement_create

2)BAPI_requirement_change

i)my program is taking data from my flat file but it is wipping out old data i nned to update not to overwrite is there any BAPI for this query

ii)One more thing if data is already entered in on date (i.e 10.07.2009) and when he upload data from flat file for another date same month (12.07.2009) old date data sholud not removed ...

Please reply me if my query is not understand..

Thanks in advance..

4 REPLIES 4

Former Member
0 Kudos

Hello,

I did the following:

1 - used BAPI_REQUIREMENTS_GETDETAIL to get existing requirements.

2 - added new requirements to this table

3 - used BAPI_REQUIREMENTS_CHANGE to update data.

Hope this solve your problem.

0 Kudos

Hello Pedro,

Thanks for replying ..

Can i get the code for the same ..

0 Kudos

Assuming you have your new requirements in table IT_REQ.

You could do something like:


DATA: it_req TYPE TABLE OF BAPISSHDIN.
DATA: l_req TYPE BAPISSHDIN.
DATA: it_req_out TYPE TABLE OF bapisitmeo.
DATA: l_req_out TYPE bapisitmeo.


*   Get existing requirements
    CLEAR it_req_out[].
    CALL FUNCTION 'BAPI_REQUIREMENTS_GETDETAIL'
         EXPORTING
              material         = p_matnr
              plant            = p_werks
              requirementstype = p_bedae
              version          = p_versb
              reqmtsplannumber = ''
         TABLES
              requirements_out = it_req_out[]
              return           = lt_return[].

*   Append old requirements to requirements table
    LOOP AT it_req_out INTO l_req_out.
      MOVE: l_req_out-date_type TO l_req-date_type,
            l_req_out-req_date TO l_req-req_date,
            l_req_out-req_qty TO l_req-req_qty,
            l_req_out-unit TO l_req-unit.
      APPEND l_req TO it_req.
    ENDLOOP.

*   Change requirements
    CALL FUNCTION 'BAPI_REQUIREMENTS_CHANGE'
         EXPORTING
              material                 = p_matnr
              plant                    = p_werks
              requirementstype         = p_bedae
              version                  = p_versb
              reqmtsplannumber         = ''
              vers_activ               = p_vervs
         TABLES
              requirements_schedule_in = it_req[]
              return                   = lt_return[].

Former Member
0 Kudos

Before using the BAPI_REQUIREMENT_CREATE, fire a query on PBIM table with material,plant,version to find out whether the record already exists in the system. If yes then use change BAPI or else use create BAPI.