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: 

Issue while updating sales order scehdule line using BAPI_SALESORDER_CHANGE

kamalakar_reddy2
Explorer
0 Kudos
2,505

Hello All ,

While I am trying to udpates the schedule line dates with BAPI_SALESORDER_CHANGE its working for frist scehdule line of line item . If I am udpating second schedule line of same line item its giving error as

'System error: Schedule line 0002 for item 000010 does not exist'.

Can you please me know if you people came across same issue or any idea to resolve this error .

Thanks,

Kamalakar.

9 REPLIES 9

Jelena
Active Contributor
0 Kudos
504

Not sure how this could be answered... There is no code shared, no data, no screenshots, not clear what has been done so far to troubleshoot this. If the message says the line doesn't exist then it doesn't exist. ¯\_(ツ)_/¯

Google -> BAPI_SALESORDER_CHANGE update schedule line date site:sap.com -> 927 results, might want to start there.

kamalakar_reddy2
Explorer
0 Kudos
504

Hello Jalena,

Thanks for your response .

Please find my code below .

LOOP AT me->lt_order REFERENCE INTO me->lr_order
WHERE vbeln NE lv_vbeln.
lv_vbeln = me->lr_order->vbeln.
ls_order_header_in-dlvschduse = 'WAP'.
ls_order_header_inx-dlvschduse = 'X'.

ls_order_header_in-dun_date = lr_order->datum.

ls_order_header_inx-dun_date = 'X'.

ls_order_header_inx-updateflag = 'U'.

LOOP AT lt_vbap INTO ls_vbap WHERE vbeln = me->lr_order->vbeln.
* ls_item-vbeln = ls_vbap-vbeln.
ls_item-itm_number = ls_vbap-posnr.
APPEND ls_item TO lt_items.
ls_itemx-itm_number = ls_vbap-posnr.
ls_itemx-updateflag = 'U'.
APPEND ls_itemx TO lt_itemsx.
LOOP AT lt_vbep INTO ls_vbep WHERE vbeln = ls_vbap-vbeln
AND posnr = ls_vbap-posnr.

ls_schedule_lines-itm_number = ls_vbep-posnr.
ls_schedule_lines-sched_line = ls_vbep-etenr."'0001'.
ls_schedule_lines-load_date = ls_order_header_in-dun_date.
ls_schedule_lines-gi_date = ls_order_header_in-dun_date.
ls_schedule_lines-tp_date = ls_order_header_in-dun_date.
ls_schedule_lines-ms_date = ls_order_header_in-dun_date .
ls_schedule_lines-req_date = ls_order_header_in-dun_date .

ls_schedule_lines-req_date = ls_schedule_lines-req_date + lv_days1.

APPEND ls_schedule_lines TO lt_schedule_lines.

ls_schedulex-itm_number = ls_vbep-posnr.
ls_schedulex-sched_line = ls_vbep-etenr."'0001'.
ls_schedulex-updateflag = 'U'.
ls_schedulex-load_date = 'X'.
ls_schedulex-ms_date = 'X'.
ls_schedulex-gi_date = 'X'.
ls_schedulex-tp_date = 'X'.
ls_schedulex-req_date = 'X'.
* ls_schedulex-date_type = 'X'.
APPEND ls_schedulex TO lt_schedulex.

ENDloop.

ENDLOOP.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
SALESDOCUMENT = me->lr_order->vbeln
ORDER_HEADER_IN = ls_order_header_in
ORDER_HEADER_INX = ls_order_header_inx
SIMULATION = p_simul
TABLES
RETURN = lt_return
ORDER_ITEM_IN = lt_items
ORDER_ITEM_INX = lt_itemsx
SCHEDULE_LINES = lt_schedule_lines
SCHEDULE_LINESX = lt_schedulex

.
* ...committen
IF p_simul IS INITIAL .
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.

Its working only if line item has 1 schedule line if it has more than one schedule line its giving error for second schedule line of item.

Thanks,

Kamalakar.

0 Kudos
504

Hi,

ls_schedule_lines-load_date = ls_order_header_in-dun_date.
ls_schedule_lines-gi_date = ls_order_header_in-dun_date.
ls_schedule_lines-tp_date = ls_order_header_in-dun_date.
ls_schedule_lines-ms_date = ls_order_header_in-dun_date .
ls_schedule_lines-req_date = ls_order_header_in-dun_date .

ls_schedule_lines-req_date = ls_schedule_lines-req_date + lv_days1.

I do not know what is your initial requirement but you are updating all schedule lines with the same info.. is that normal ? Shouldn't you update only last schedule line in the order by any chance?

VeselinaPeykova
Active Contributor
0 Kudos
504

What I usually do in such cases (I am not a developer) is to create test data in SE37 for the same order and execute test sequence of BAPI_SALESORDER_CHANGE and BAPI_TRANSACTION_COMMIT. If the schedule lines are updated correctly via SE37 but not via the program then the problem is with the custom code, so I would place a break point to find out what are the differences between the values of the parameters in SE37 and in the z* program.

If the same error appears in SE37 and in the z* program I would use BAPISDORDER_GETDETAILEDLIST to verify the schedule lines for each item before executing the test sequence in SE37 (in fact I would do this before trying anything else).

Another troubleshooting option that I use is modifying the document via VA02. If SE37 and the Z* program do not work as expected , but VA02 does I would look for anything related to screen logic, hard-coded TCODE etc.

Of course, an experienced developer should be able to troubleshoot the problem simply by debugging (which may be time-consuming), but as I am not one - I use the techniques that I mentioned before asking a developer for assistance.

0 Kudos
504

check this code....

DATA: BAPISDH1X LIKE BAPISDH1X.DATA: BAPISDH1 LIKE BAPISDH1.PARAMETERS: P_VBELN LIKE VBAK-VBELN OBLIGATORY.PARAMETERS: P_LIFSK  LIKE VBAK-LIFSK OBLIGATORY.
* Header 
BAPISDH1-DLV_BLOCK = p_lifsk." Delivery block
* header X
BAPISDH1X-DLV_BLOCK ='X'." Delivery block
BAPISDH1X-UPDATEFLAG ='U'.CALLFUNCTION'BAPI_SALESORDER_CHANGE'EXPORTING
salesdocument = P_VBELN
order_header_in   = BAPISDH1
order_header_inx = BAPISDH1X
tablesreturn= T_RETURN
.LOOPAT T_RETURN WHERETYPE='E'ORTYPE='A'.EXIT.ENDLOOP.
* Check for error messages.IFSY-SUBRC =0.WRITE:/'Sales order not updated', T_RETURN-MESSAGE.ELSE. 

* Successfully updatedWRITE:/'Sales order updated'.ENDIF.COMMIT WORK.

Read More: SAP ABAP Certifications

kamalakar_reddy2
Explorer
0 Kudos
504

Hi dev ,

Thanks for your input .

You are right I am trying to update all the schedule lines with same date and req date with date plus days . If schedule line doesnt have confirmed qty then its working fine . If schedule lines has more than 1 line for line item and schedule line with confrimed qty then its error as 'Schedule line 0002 for item 000010 does not exist'.

Thanks,

Kamalakar.

0 Kudos
504

Hi Kamalakar Reddy,

Are you able to change via VA02. Please go through Snote 2656766 - Error V1335 hen modifying a sales document.

Cause

  • A possible reason why this error is occurring is because for a line item, for example 10, in a sales order, there are two schedule lines.
  • The schedule line 0001 contained the requested delivery date, the schedule line 0002 contained the confirmed delivery date.
  • Because the requested delivery date and the confirmed delivery date are not the same date, there are 2 schedule lines in the sales order.

Resolution

  1. The solution in this case is that you only have to update the first schedule line which contains the requested delivery date.
    1. The second schedule line cannot be processed because it is not ready for input, leading to the error message V1335.
  2. Please refer to note655666for more details on this issue. As described in the note, there can be no standard solution provided to this problem due to the different error possibilities.
    1. However, the note provides a modification option if you want a further processing instead of an error message to occur.

Regards

Mukhtar

kamalakar_reddy2
Explorer
0 Kudos
504

Hi Genia Scott ,

No luck 😞

Still with same error System error: Schedule line 0002 for item 000010 does not exist

Thanks,

Kamalakar

kamalakar_reddy2
Explorer
0 Kudos
504

Hello Mukhtar

Thanks alot for the input .

Solution which I have implemented is to discard the schdule line items in which required qty is 0.

BAPI will adjust the dates and schdule line items.

Thanks,

Kamalakar.