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: 

Schdule line upload using bapi_saleorder_change

Former Member
0 Kudos
99

Dear Experts,

We tried to upload schedule lines using  bapi_salesorder_change.  after executing the bapi in background we are getting message as processed successfully.  When we checked schedule agreement the schedules lines are not updated.

Please help.

-


*

*& Report  ZBAPI_VA32_TEST

*&

&---- 

*&

*&

&---- 

REPORT  ZBAPI_VA32_TEST.

DATA: lvbak TYPE vbak.

DATA:

v_vbeln TYPE bapivbeln-vbeln,

v_order_header_inx TYPE bapisdh1x,

i_item TYPE TABLE OF bapisditm WITH HEADER LINE,

i_itemx TYPE TABLE OF bapisditmx WITH HEADER LINE,

i_schedule_lines TYPE TABLE OF bapischdl WITH HEADER LINE,

i_schedule_linesx TYPE TABLE OF bapischdlx WITH HEADER LINE,

i_return TYPE TABLE OF bapiret2 WITH HEADER LINE.

DATA: lposnr TYPE vbap-posnr.

PARAMETERS: pvbeln TYPE vbak-vbeln OBLIGATORY.

v_order_header_inx-updateflag = 'U'.

v_vbeln             = pvbeln.

i_item-itm_number   = '000010'.

i_itemx-itm_number   = '000010'.

i_itemx-updateflag   = 'U'.

i_schedule_lines-itm_number = '000010'.

i_schedule_lines-sched_line = '0006'.

i_schedule_lines-req_date = sy-datum.

i_schedule_lines-req_qty = '6'.

i_schedule_linesx-itm_number = '000010'.

i_schedule_linesx-sched_line = '0006'.

i_schedule_linesx-updateflag = 'I'.

i_schedule_linesx-req_date = 'X'.

i_schedule_linesx-req_qty = 'X'.

APPEND i_item.

APPEND i_itemx.

APPEND i_schedule_lines.

APPEND i_schedule_linesx.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

  EXPORTING

    salesdocument    = v_vbeln

    order_header_inx = v_order_header_inx

  TABLES

    return           = i_return

    order_item_in    = i_item

    order_item_inx   = i_itemx

    SCHEDULE_LINES   = i_schedule_lines

    SCHEDULE_LINESX  = i_schedule_linesx.

LOOP AT i_return WHERE type = 'A' OR type = 'E'.

  EXIT.

ENDLOOP.

IF sy-subrc ne 0.

  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

ENDIF.


 


6 REPLIES 6

former_member190103
Participant
0 Kudos
64

Hi hari,

I have debugged this program . While i am debugging this i am getting messages into I_return[] field.

"SD document 30000 is not in the database or has been archived"

I have given vbeln value is "30000".

Try to debug this program once and let us know if you are getting values are not.

Cheers,

Sravan

0 Kudos
64

Dear Mr.Sravan,

Thanks for your reply.

We have already debugged the program & the agreement is available in database also.

We are getting following messages.

Return messages

Order header in has been processed successfully

Item_in processed successfully

Schedule_in has been processed successfully

sch agreement 3102849 has been saved

The same is working in one of our other client server.  But its not working here.

Please help.

0 Kudos
64

Hi Hari,

After COMMIT WORK have you used ROLLBACK.

Cheers,

Sravan

Former Member
0 Kudos
64

Hi Hari,

Change this Code .

LOOP AT i_return WHERE type = 'A' OR type = 'E'.

  EXIT.

ENDLOOP.

IF sy-subrc ne 0.

  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

ENDIF.

==========================================

New Code : (Replace with above Code ).

i_return  LIKE BAPIRET2  OCCURS 0 WITH HEADER LINE.

READ TABLE  i_return WITH KEY TYPE = 'E' OR TYPE = 'A' .

   IF SY-SUBRC EQ '0'.

      EXIT.

     ELSE.

       CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

  ENDIF.  

Regard's

Smruti


Former Member
0 Kudos
64

Hi,

I hope this example helped you

READ TABLE i_return WITH KEY type = 'E'.
     IF sy-subrc = 0.
*If you want you can manage the message
       CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
     ELSE.
       CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
         EXPORTING
           wait = 'X'.
     ENDIF.

Regards

Ivan

Former Member
0 Kudos
64

Dear All,

Thanks for your reply.

We got the solution by passing release type for the schedule lines & its working fine.

Once again thanks a lot.