Application Development and Automation 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: 
Read only

BAPI_PO_CHANGE with scheduling

Former Member
0 Likes
3,765

Hai frnds,

Im using BAPI_PO_CHANGE for changing the quantity of the existing item and need to create an new item also. For this im using scheduling table(poschedule),where one item has two scheduling line.

Existing details

Eg: POHEADER: 0210000001

POITEM:

10 -> 400(quantity)

POSCHEDULE:

10 -> 1(1st sched) -> 100(quantity)

10 -> 2(2nd sched) -> 300(quantity)

After modification

Eg: POHEADER: 0210000001

POITEM:

10 -> 60(quantity)

20 -> 340(quantity)

POSCHEDULE:

10 -> 1(1st sched) -> 60(quantity)

10 -> 2(2nd sched) -> 0(quantity)

20 -> 1(1st sched) -> 40(quantity)

20 -> 2(2nd sched) -> 300(quantity)

Can anyone help me to solve this problem??? wat are the fields to be considered in POITEM,POSCHEDULE?

Suganya Jayabalan.

1 ACCEPTED SOLUTION
Read only

Former Member
3,311

Suganya,

See an example for PO schedule line change. Similarly you could make changes to the quantity also.

rgds,

TM.

Please mark points if helpful.

  wa_poschedule-po_item = '00010'.
  wa_poschedule-sched_line = '0001'.
  CONCATENATE p_date+6(2) '.' p_date+4(2) '.' p_date+0(4)
  INTO wa_poschedule-delivery_date.
  APPEND wa_poschedule TO poschedule.

  wa_poschedule-sched_line = '0002'.
  CONCATENATE p_date+6(2) '.' p_date+4(2) '.' p_date+0(4)
  INTO wa_poschedule-delivery_date.
  APPEND wa_poschedule TO poschedule.

  wa_poschedulex-po_item = '00010'.
  wa_poschedulex-sched_line = '0001'.
  wa_poschedulex-po_itemx = 'X'.
  wa_poschedulex-delivery_date = 'X'.
  APPEND wa_poschedulex TO poschedulex.

  wa_poschedulex-po_item = '00010'.
  wa_poschedulex-sched_line = '0002'.
  wa_poschedulex-po_itemx = 'X'.
  wa_poschedulex-delivery_date = 'X'.
  APPEND wa_poschedulex TO poschedulex.

  CALL FUNCTION 'BAPI_PO_CHANGE'
       EXPORTING
            purchaseorder = purchaseorder
       TABLES
            return        = return
            poschedule    = poschedule
            poschedulex   = poschedulex.
. 

17 REPLIES 17
Read only

Former Member
3,312

Suganya,

See an example for PO schedule line change. Similarly you could make changes to the quantity also.

rgds,

TM.

Please mark points if helpful.

  wa_poschedule-po_item = '00010'.
  wa_poschedule-sched_line = '0001'.
  CONCATENATE p_date+6(2) '.' p_date+4(2) '.' p_date+0(4)
  INTO wa_poschedule-delivery_date.
  APPEND wa_poschedule TO poschedule.

  wa_poschedule-sched_line = '0002'.
  CONCATENATE p_date+6(2) '.' p_date+4(2) '.' p_date+0(4)
  INTO wa_poschedule-delivery_date.
  APPEND wa_poschedule TO poschedule.

  wa_poschedulex-po_item = '00010'.
  wa_poschedulex-sched_line = '0001'.
  wa_poschedulex-po_itemx = 'X'.
  wa_poschedulex-delivery_date = 'X'.
  APPEND wa_poschedulex TO poschedulex.

  wa_poschedulex-po_item = '00010'.
  wa_poschedulex-sched_line = '0002'.
  wa_poschedulex-po_itemx = 'X'.
  wa_poschedulex-delivery_date = 'X'.
  APPEND wa_poschedulex TO poschedulex.

  CALL FUNCTION 'BAPI_PO_CHANGE'
       EXPORTING
            purchaseorder = purchaseorder
       TABLES
            return        = return
            poschedule    = poschedule
            poschedulex   = poschedulex.
. 

Read only

0 Likes
3,311

hai Thomas,

This is wat i tried:

PURCHASEORDER = '0210000001'.

POITEM-po_item = '00010'.

POITEM-quantity = '60'.

POITEM-gr_basediv = ' '.

append POITEM.

POITEM-po_item = '00020'.

POITEM-quantity = '340'.

POITEM-gr_basediv = 'X'.

POITEM-preq_no = '10002902'.

POITEM-preq_item = '00010'.

append POITEM.

POITEMX-po_item = '00010'.

POITEMX-po_itemx = 'X'.

POITEMX-quantity = 'X'.

POITEMX-gr_basediv = 'X'.

append POITEMX.

POITEMX-po_item = '00020'.

POITEMX-po_itemx = 'X'.

POITEMX-quantity = 'X'.

POITEMX-gr_basediv = 'X'.

POITEMX-preq_no = 'X'.

POITEMX-preq_item = 'X'.

append POITEMX.

POSCHEDULE-po_item = '00010'.

POSCHEDULE-sched_line = '0001'.

POSCHEDULE-quantity = '60'.

POSCHEDULE-preq_no = '10002902'.

POSCHEDULE-preq_item = '00010'.

append POSCHEDULE.

POSCHEDULE-po_item = '00010'.

POSCHEDULE-sched_line = '0002'.

POSCHEDULE-quantity = '0'.

POSCHEDULE-preq_no = '10002903'.

POSCHEDULE-preq_item = '00010'.

append POSCHEDULE.

POSCHEDULE-po_item = '00020'.

POSCHEDULE-sched_line = '0001'.

POSCHEDULE-quantity = '40'.

POSCHEDULE-preq_no = '10002902'.

POSCHEDULE-preq_item = '00010'.

append POSCHEDULE.

POSCHEDULE-po_item = '00020'.

POSCHEDULE-sched_line = '0002'.

POSCHEDULE-quantity = '300'.

POSCHEDULE-preq_no = '10002903'.

POSCHEDULE-preq_item = '00010'.

append POSCHEDULE.

POSCHEDULEX-po_item = '00010'.

POSCHEDULEX-sched_line = '0001'.

POSCHEDULEX-po_itemx = 'X'.

POSCHEDULEX-sched_linex = 'X'.

POSCHEDULEX-quantity = 'X'.

append POSCHEDULEX.

POSCHEDULEX-po_item = '00010'.

POSCHEDULEX-sched_line = '0002'.

POSCHEDULEX-po_itemx = 'X'.

POSCHEDULEX-sched_linex = 'X'.

POSCHEDULEX-delete_ind = 'X'.

append POSCHEDULEX.

POSCHEDULEX-po_item = '00020'.

POSCHEDULEX-sched_line = '0001'.

POSCHEDULEX-po_itemx = 'X'.

POSCHEDULEX-sched_linex = 'X'.

POSCHEDULEX-quantity = 'X'.

POSCHEDULEX-preq_no = 'X'.

POSCHEDULEX-preq_item = 'X'.

append POSCHEDULEX.

POSCHEDULEX-po_item = '00020'.

POSCHEDULEX-sched_line = '0002'.

POSCHEDULEX-po_itemx = 'X'.

POSCHEDULEX-sched_linex = 'X'.

POSCHEDULEX-quantity = 'X'.

POSCHEDULEX-preq_no = 'X'.

POSCHEDULEX-preq_item = 'X'.

append POSCHEDULEX.

anything wrong in this?????

Suganya Jayabalan.

Read only

0 Likes
3,311

Suganya,

Check with this code... It's will change the schedule line qty...

rgds,

TM.

Please mark points if helpful.

REPORT zpo_change_tm.

DATA: purchaseorder LIKE  bapimepoheader-po_number VALUE '0004510042'.

DATA: wa_poschedule TYPE bapimeposchedule,
      wa_poschedulex TYPE bapimeposchedulx.

DATA: return LIKE  bapiret2 OCCURS 0,
      poschedule LIKE bapimeposchedule OCCURS 0,
      poschedulex LIKE  bapimeposchedulx OCCURS 0.


wa_poschedule-po_item = '00010'.
wa_poschedule-sched_line = '0001'.

wa_poschedule-quantity = 3.
APPEND wa_poschedule TO poschedule.

wa_poschedule-sched_line = '0002'.
wa_poschedule-quantity = 4.
APPEND wa_poschedule TO poschedule.

wa_poschedulex-po_item = '00010'.
wa_poschedulex-sched_line = '0001'.
wa_poschedulex-po_itemx = 'X'.
wa_poschedulex-quantity = 'X'.
APPEND wa_poschedulex TO poschedulex.

wa_poschedulex-po_item = '00010'.
wa_poschedulex-sched_line = '0002'.
wa_poschedulex-po_itemx = 'X'.
wa_poschedulex-quantity = 'X'.
APPEND wa_poschedulex TO poschedulex.

CALL FUNCTION 'BAPI_PO_CHANGE'
     EXPORTING
          purchaseorder = purchaseorder
     TABLES
          return        = return
          poschedule    = poschedule
          poschedulex   = poschedulex.

BREAK-POINT.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'         .

Read only

0 Likes
3,311

hai Thomas,

Thanks for the reply...i tried ur code but its not changing the quantity. when i change the quantity in scheduling it should change the poitem quantity also. i tried but its not changing.

regrads,

suganya Jayabalan

Read only

0 Likes
3,311

Suganya,

The code which i have posted is working fine with me.

Basically if you change the Schedule line quantity, it will automatically adjust the line item quantity also. You don’t need to feed that value separately using bapi. ie In your case 340 is not needed to assign to POITEM-quantity. Hence you can avoid that part of the code.

Check the relevance of PR number in your bapi. Is that also needed to be change ?

Can you see what exactly the messages are coming in return table? Is there any Error coming in your case?

rgds,

TM.

Read only

0 Likes
3,311

hai Thomas,

Currently im changing the code of an existing logic,where they are changing the quantity for the existing item and creating an new one using POITEM only. but the scheduling have only one sched line. so its working fine.

But i have to do for two sched line where its throwing an error like this:

1)Materials of requisition 10002902 item 00010 alr.

ordered in full

2)Materials of requisition 10002903 item 00010 alr.

ordered in full

the first line item they will make the gr_basediv as ' ' and second item as 'X'.so in POITEM both changing and creating will be there.

Regrads,

suganya Jayabalan

Read only

0 Likes
3,311

hai Thomas,

ok i will check with ur advice and test it.if u need i will send the code also....

regrads,

Suganya Jayabalan.

Read only

0 Likes
3,311

Hai Thomas,

This was the message during the excution of the code send by you:

1)PO MCBS, Maheshtala 210000001 changed(Status message)

2)No message generated for output of purchasing document(Warning message)

Regrads,

suganya Jayabalan.

Read only

0 Likes
3,311

Suganya,

The Message 1(PO MCBS, Maheshtala 210000001 changed(Status message) ) clearly states that the PO is changed. For bring the changes into the table, make sure that BAPI commit is executed.

And regarding your changes, If you need to do any changes to the respective PR of the PO then you can make use of BAPI - <b>BAPI_REQUISITION_CHANGE</b>.

In you code posted above I could not find any releveance of Pur Req assignment, if not needed then remove it. I could see the error coming from Pur req only(Materials of requisition 10002902 item 00010 alr. ordered in full)

I understand that for the first line item you want to avoid GR-based invoice verification and the same is needed for second. That part of the code is fine.

Hence, as the message says the error comes from Pur Req.. Check it out..

rgds,

TM.

Read only

0 Likes
3,311

Hai Thomas,

I have used ur coding,i.e., with BAPI_TRANSACTION_COMMIT. but the error came is:

1)PO MCBS, Maheshtala 210000001 changed

2)No message generated for output of purchasing document

This error was in RETURN table. But wen i checked with ME23N for that PO it was remaining the samei.e., no change.

The purchase req in new item is base,as everything refers to this PR.In scheduling, they have two PR so it will be needed(i think so). Any change in my thought,plz inform me.

Regrads,

Suganya Jayabalan.

Read only

0 Likes
3,311

Suganya,

For my code as you said 2 messages are generated

1) Status Message which says PO is changed

2) Warning message, which will never prevent from changing the document.

Both of them are not error messages. There is no any <i>Error messages</i> in the return code, that means the BAPI will make changes.

If you could post your complete code I could check on that.

rgds,

TM.

Read only

0 Likes
3,311

Hai Thomas,

this is the code:

REPORT zfi_upd_import_process NO STANDARD PAGE HEADING

MESSAGE-ID z6 .

TABLES: zmmpoamend,ekko, ekpo.

DATA:t_zmmpo_amend_tab LIKE zmmpoamend OCCURS 0 WITH HEADER LINE.

DATA:t_zmmpo_amend_tab1 LIKE zmmpoamend OCCURS 0 WITH HEADER LINE.

DATA:v_bstmg LIKE bapimepoitem-quantity,

v_ebelp LIKE bapimepoitem-po_item,

v_belnr1 LIKE bkpf-belnr,

v_awkey LIKE bkpf-awkey,

v_orderunit LIKE ekpo-meins,

v_currency LIKE tcurc-waers,

v_ebeln LIKE ekko-ebeln,

v_payterm LIKE ekko-zterm,

v_zfbdt LIKE bseg-zfbdt,

v_flag(1) TYPE c,

v_flgbdc(1) TYPE c.

DATA: wa_bapiquantity1 like eket-menge,

wa_bapiquanfin1 like eket-menge,

wa_bapiquantot like eket-menge,

wa_bapiquantity2 like eket-menge,

wa_bapiquanfin2 like eket-menge.

DATA: BEGIN OF t_belnr_tab OCCURS 0,

belnr LIKE bkpf-belnr,

gjahr LIKE bkpf-gjahr,

END OF t_belnr_tab.

DATA: BEGIN OF t_ret_tab OCCURS 0.

INCLUDE STRUCTURE bapiret2.

DATA: END OF t_ret_tab.

                • FOR PO AMENDMENT POSTING ****************

DATA:BEGIN OF t_bapimepocond_tab OCCURS 0.

INCLUDE STRUCTURE bapimepocond.

DATA:END OF t_bapimepocond_tab.

DATA:BEGIN OF t_bapimepoitem_tab OCCURS 0.

INCLUDE STRUCTURE bapimepoitem.

DATA:END OF t_bapimepoitem_tab.

DATA: t_bapimepoitem_tab1 LIKE t_bapimepoitem_tab OCCURS 0 WITH HEADER

LINE

.

DATA:BEGIN OF t_bapimepoitemdet_tab OCCURS 0.

INCLUDE STRUCTURE bapiekpo.

DATA:END OF t_bapimepoitemdet_tab.

DATA:BEGIN OF t_bapieket_tab OCCURS 0.

INCLUDE STRUCTURE bapieket.

DATA:END OF t_bapieket_tab.

DATA:BEGIN OF t_bapiposchedule OCCURS 0.

INCLUDE STRUCTURE BAPIMEPOSCHEDULE.

DATA:END OF t_bapiposchedule.

data: w_no type i,

w_no1 type i,

w_idx type i.

DATA: w_ebelp like ekpo-ebelp.

DATA:BEGIN OF t_bapimepoaccount_tab OCCURS 0.

INCLUDE STRUCTURE bapimepoaccount.

DATA:END OF t_bapimepoaccount_tab.

DATA:BEGIN OF t_bapimepoaccountx_tab OCCURS 0.

INCLUDE STRUCTURE bapimepoaccountx.

DATA:END OF t_bapimepoaccountx_tab.

DATA:BEGIN OF t_bapimepoaccountdet_tab OCCURS 0.

INCLUDE STRUCTURE bapiekkn.

DATA:END OF t_bapimepoaccountdet_tab.

DATA:BEGIN OF t_bapimepoitemx_tab OCCURS 0.

INCLUDE STRUCTURE bapimepoitemx.

DATA:END OF t_bapimepoitemx_tab.

DATA:wa_bapimepoitem LIKE LINE OF t_bapimepoitem_tab.

data: begin of t_bapiposchedulex occurs 0.

include structure BAPIMEPOSCHEDULX.

data: end of t_bapiposchedulex.

                • END OF FOR PO AMENDMENT POSTING **********

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETERS: p_poamd RADIOBUTTON GROUP rad1,

p_mirofs RADIOBUTTON GROUP rad1,

p_mirocd RADIOBUTTON GROUP rad1,

p_mirofr RADIOBUTTON GROUP rad1,

p_j1iex RADIOBUTTON GROUP rad1.

SELECT-OPTIONS:s_zzboe FOR zmmpoamend-zzboe NO INTERVALS NO-EXTENSION

OBLIGATORY.

SELECTION-SCREEN END OF BLOCK b1.

IF p_poamd = 'X'.

            • begin of internal table processing for calling BAPI's*******

SELECT * FROM zmmpoamend INTO TABLE t_zmmpo_amend_tab

WHERE zzboe IN s_zzboe AND

zzpostat = ' '.

IF sy-subrc <> '0'.

MESSAGE 'No PO found which has to be updated.' TYPE 'E'.

ENDIF.

                                • begin of PO Amendment****************

LOOP AT t_zmmpo_amend_tab .

t_zmmpo_amend_tab-waers = 'INR'.

t_zmmpo_amend_tab1 = t_zmmpo_amend_tab.

t_zmmpo_amend_tab1-zzpostat = 'X'.

APPEND t_zmmpo_amend_tab1.

IF t_zmmpo_amend_tab-zzwrbtrvcd NE '0'.

CLEAR t_bapimepocond_tab.

t_bapimepocond_tab-itm_number = t_zmmpo_amend_tab-ebelp.

t_bapimepocond_tab-cond_value = t_zmmpo_amend_tab-zzwrbtrvcd.

t_bapimepocond_tab-cond_type = 'ZVCD'.

t_bapimepocond_tab-currency = t_zmmpo_amend_tab-waers.

t_bapimepocond_tab-change_id = 'I'.

APPEND t_bapimepocond_tab.

ENDIF.

IF t_zmmpo_amend_tab-zzwrbtrvnv NE '0'.

CLEAR t_bapimepocond_tab.

t_bapimepocond_tab-itm_number = t_zmmpo_amend_tab-ebelp.

t_bapimepocond_tab-cond_value = t_zmmpo_amend_tab-zzwrbtrvnv.

t_bapimepocond_tab-cond_type = 'ZVNV'.

t_bapimepocond_tab-currency = t_zmmpo_amend_tab-waers.

t_bapimepocond_tab-change_id = 'I'.

APPEND t_bapimepocond_tab.

ENDIF.

IF t_zmmpo_amend_tab-zzwrbtrccd NE '0'.

CLEAR t_bapimepocond_tab.

t_bapimepocond_tab-itm_number = t_zmmpo_amend_tab-ebelp.

t_bapimepocond_tab-cond_value = t_zmmpo_amend_tab-zzwrbtrccd.

t_bapimepocond_tab-cond_type = 'ZCCD'.

t_bapimepocond_tab-currency = t_zmmpo_amend_tab-waers.

t_bapimepocond_tab-change_id = 'I'.

APPEND t_bapimepocond_tab.

ENDIF.

IF t_zmmpo_amend_tab-zzwrbtrvcv NE '0'.

CLEAR t_bapimepocond_tab.

t_bapimepocond_tab-itm_number = t_zmmpo_amend_tab-ebelp.

t_bapimepocond_tab-cond_value = t_zmmpo_amend_tab-zzwrbtrvcv.

t_bapimepocond_tab-cond_type = 'ZVCV'.

t_bapimepocond_tab-currency = t_zmmpo_amend_tab-waers.

t_bapimepocond_tab-change_id = 'I'.

APPEND t_bapimepocond_tab.

ENDIF.

IF t_zmmpo_amend_tab-zzwrbtrvce NE '0'.

CLEAR t_bapimepocond_tab.

t_bapimepocond_tab-itm_number = t_zmmpo_amend_tab-ebelp.

t_bapimepocond_tab-cond_value = t_zmmpo_amend_tab-zzwrbtrvce.

t_bapimepocond_tab-cond_type = 'ZVCE'.

t_bapimepocond_tab-currency = t_zmmpo_amend_tab-waers.

t_bapimepocond_tab-change_id = 'I'.

APPEND t_bapimepocond_tab.

ENDIF.

IF t_zmmpo_amend_tab-zzwrbtrvfi NE '0'.

CLEAR t_bapimepocond_tab.

t_bapimepocond_tab-itm_number = t_zmmpo_amend_tab-ebelp.

t_bapimepocond_tab-cond_value = t_zmmpo_amend_tab-zzwrbtrvfi.

t_bapimepocond_tab-cond_type = 'ZVFI'.

t_bapimepocond_tab-currency = t_zmmpo_amend_tab-waers.

t_bapimepocond_tab-change_id = 'I'.

APPEND t_bapimepocond_tab.

ENDIF.

IF t_zmmpo_amend_tab-zzwrbtrvad NE '0'.

CLEAR t_bapimepocond_tab.

t_bapimepocond_tab-itm_number = t_zmmpo_amend_tab-ebelp.

t_bapimepocond_tab-cond_value = t_zmmpo_amend_tab-zzwrbtrvad.

t_bapimepocond_tab-cond_type = 'ZVAD'.

t_bapimepocond_tab-currency = t_zmmpo_amend_tab-waers.

t_bapimepocond_tab-change_id = 'I'.

APPEND t_bapimepocond_tab.

ENDIF.

IF t_zmmpo_amend_tab-zzwrbtrvac NE '0'.

    • ZVAC added..

CLEAR t_bapimepocond_tab.

t_bapimepocond_tab-itm_number = t_zmmpo_amend_tab-ebelp.

t_bapimepocond_tab-cond_value = t_zmmpo_amend_tab-zzwrbtrvac.

t_bapimepocond_tab-cond_type = 'ZVAC'.

t_bapimepocond_tab-currency = t_zmmpo_amend_tab-waers.

t_bapimepocond_tab-change_id = 'I'.

APPEND t_bapimepocond_tab.

ENDIF.

IF t_zmmpo_amend_tab-zzwrbtrvae NE '0'.

    • ZVAE added..

CLEAR t_bapimepocond_tab.

t_bapimepocond_tab-itm_number = t_zmmpo_amend_tab-ebelp.

t_bapimepocond_tab-cond_value = t_zmmpo_amend_tab-zzwrbtrvae.

t_bapimepocond_tab-cond_type = 'ZVAE'.

t_bapimepocond_tab-currency = t_zmmpo_amend_tab-waers.

t_bapimepocond_tab-change_id = 'I'.

APPEND t_bapimepocond_tab.

ENDIF.

IF t_zmmpo_amend_tab-zzwrbtrmis NE '0'.

    • ZMIS(Miscellaenous charges) added..

CLEAR t_bapimepocond_tab.

t_bapimepocond_tab-itm_number = t_zmmpo_amend_tab-ebelp.

t_bapimepocond_tab-cond_value = t_zmmpo_amend_tab-zzwrbtrmis.

t_bapimepocond_tab-cond_type = 'ZMIS'.

t_bapimepocond_tab-currency = t_zmmpo_amend_tab-waers.

t_bapimepocond_tab-change_id = 'I'.

APPEND t_bapimepocond_tab.

ENDIF.

IF t_zmmpo_amend_tab-zzinsper NE '0'.

  • insurance

CLEAR t_bapimepocond_tab.

t_bapimepocond_tab-itm_number = t_zmmpo_amend_tab-ebelp.

t_bapimepocond_tab-cond_value = t_zmmpo_amend_tab-zzinsper.

t_bapimepocond_tab-cond_type = 'ZPIN'.

t_bapimepocond_tab-currency = '%'. "zmmpo_amend_tab-waers.

t_bapimepocond_tab-change_id = 'I'.

APPEND t_bapimepocond_tab.

ENDIF.

IF t_zmmpo_amend_tab-zzclsper NE '0'.

*clearing charges.

CLEAR t_bapimepocond_tab.

t_bapimepocond_tab-itm_number = t_zmmpo_amend_tab-ebelp.

t_bapimepocond_tab-cond_value = t_zmmpo_amend_tab-zzclsper.

t_bapimepocond_tab-cond_type = 'ZPCL'.

t_bapimepocond_tab-currency = '%'. "zmmpo_amend_tab-waers.

t_bapimepocond_tab-change_id = 'I'.

APPEND t_bapimepocond_tab.

ENDIF.

v_bstmg = t_zmmpo_amend_tab1-menge + v_bstmg.

AT END OF ebelp.

  • t_bapimepoitem_tab-po_number = t_zmmpo_amend_tab1-ebeln .

t_bapimepoitem_tab-po_item = t_zmmpo_amend_tab1-ebelp .

t_bapimepoitem_tab-quantity = v_bstmg.

APPEND t_bapimepoitem_tab.

CLEAR v_bstmg.

ENDAT.

AT END OF ebeln.

  • L_EBELN =

CALL FUNCTION 'BAPI_PO_GETDETAIL'

EXPORTING

purchaseorder = t_zmmpo_amend_tab-ebeln

items = 'X'

account_assignment = 'X'

SCHEDULES = 'X'

TABLES

po_items = t_bapimepoitemdet_tab

po_item_account_assignment = t_bapimepoaccountdet_tab

PO_ITEM_SCHEDULES = t_bapieket_tab.

CLEAR v_ebelp.

v_ebelp = t_bapimepoitemdet_tab-po_item.

LOOP AT t_bapimepoitem_tab.

v_bstmg = t_bapimepoitem_tab-quantity.

LOOP AT t_bapimepoitemdet_tab WHERE

po_number = t_zmmpo_amend_tab-ebeln AND

po_item = t_bapimepoitem_tab-po_item.

IF t_bapimepoitemdet_tab-quantity =

t_bapimepoitem_tab-quantity.

MOVE-CORRESPONDING t_bapimepoitemdet_tab TO wa_bapimepoitem.

wa_bapimepoitem-gr_basediv = ' '.

APPEND wa_bapimepoitem TO t_bapimepoitem_tab1.

t_bapimepoitemx_tab-po_item = wa_bapimepoitem-po_item.

t_bapimepoitemx_tab-gr_basediv = 'X'.

APPEND t_bapimepoitemx_tab.

ELSE.

v_ebelp = v_ebelp + '10'.

MOVE-CORRESPONDING t_bapimepoitemdet_tab TO wa_bapimepoitem.

wa_bapimepoitem-quantity = t_bapimepoitemdet_tab-quantity -

t_bapimepoitem_tab-quantity.

wa_bapimepoitem-po_item = v_ebelp .

APPEND wa_bapimepoitem TO t_bapimepoitem_tab1.

LOOP AT t_bapimepoaccountdet_tab

WHERE po_item = t_bapimepoitem_tab-po_item.

MOVE-CORRESPONDING t_bapimepoaccountdet_tab TO

t_bapimepoaccount_tab.

t_bapimepoaccount_tab-gl_account =

t_bapimepoaccountdet_tab-g_l_acct.

t_bapimepoaccount_tab-itm_number =

t_bapimepoaccountdet_tab-sdoc_item.

t_bapimepoaccount_tab-quantity = wa_bapimepoitem-quantity.

t_bapimepoaccount_tab-po_item = v_ebelp.

t_bapimepoaccountx_tab-po_item = v_ebelp.

t_bapimepoaccountx_tab-quantity = 'X'.

t_bapimepoaccountx_tab-creat_date = 'X'.

t_bapimepoaccountx_tab-quantity = 'X'.

t_bapimepoaccountx_tab-gl_account = 'X'.

t_bapimepoaccountx_tab-bus_area = 'X'.

t_bapimepoaccountx_tab-costcenter = 'X'.

t_bapimepoaccountx_tab-sd_doc = 'X'.

t_bapimepoaccountx_tab-itm_number = 'X'.

t_bapimepoaccountx_tab-co_area = 'X'.

t_bapimepoaccountx_tab-part_acct = 'X'.

APPEND t_bapimepoaccount_tab.

APPEND t_bapimepoaccountx_tab.

ENDLOOP.

t_bapimepoitemx_tab-po_item = wa_bapimepoitem-po_item.

t_bapimepoitemx_tab-quantity = 'X'.

t_bapimepoitemx_tab-stge_loc = 'X'.

t_bapimepoitemx_tab-preq_no = 'X'.

t_bapimepoitemx_tab-preq_item = 'X'.

t_bapimepoitemx_tab-material = 'X'.

t_bapimepoitemx_tab-po_unit = 'X'.

t_bapimepoitemx_tab-plant = 'X'.

APPEND t_bapimepoitemx_tab.

MOVE-CORRESPONDING t_bapimepoitemdet_tab TO wa_bapimepoitem.

wa_bapimepoitem-quantity = v_bstmg.

wa_bapimepoitem-gr_basediv = ' '.

APPEND wa_bapimepoitem TO t_bapimepoitem_tab1.

t_bapimepoitemx_tab-po_item = wa_bapimepoitem-po_item.

t_bapimepoitemx_tab-quantity = 'X'.

t_bapimepoitemx_tab-gr_basediv = 'X'.

APPEND t_bapimepoitemx_tab.

*********this is wer new coding starts*****************************

*inserted for delivery scheduling foe PO

loop at t_bapieket_tab

where po_item = t_bapimepoitemdet_tab-po_item.

w_idx = sy-tabix.

IF t_bapieket_tab-SERIAL_NO = '0001'.

IF t_bapimepoitem_tab-quantity > t_bapieket_tab-quantity or

t_bapimepoitem_tab-quantity = t_bapieket_tab-quantity.

wa_bapiquantity1 = t_bapieket_tab-quantity.

ELSEIF t_bapimepoitem_tab-quantity < t_bapieket_tab-quantity.

wa_bapiquantity1 = t_bapimepoitem_tab-quantity.

ENDIF.

wa_bapiquanfin1 = t_bapieket_tab-quantity - wa_bapiquantity1.

t_bapieket_tab-QUANTITY = wa_bapiquantity1.

modify t_bapieket_tab index w_idx transporting quantity.

t_bapieket_tab-po_item = v_ebelp.

t_bapieket_tab-quantity = wa_bapiquanfin1.

append t_bapieket_tab.

ELSE.

IF t_bapimepoitem_tab-quantity > t_bapieket_tab-quantity.

wa_bapiquantity2 = t_bapimepoitem_tab-quantity - wa_bapiquantity1.

ELSEIF t_bapimepoitem_tab-quantity < t_bapieket_tab-quantity or

t_bapimepoitem_tab-quantity = t_bapieket_tab-quantity.

wa_bapiquantity2 = 0.

ENDIF.

wa_bapiquanfin2 = t_bapieket_tab-quantity - abs( wa_bapiquantity2 ).

t_bapieket_tab-QUANTITY = abs( wa_bapiquantity2 ).

modify t_bapieket_tab index w_idx transporting quantity.

t_bapieket_tab-po_item = v_ebelp.

t_bapieket_tab-quantity = wa_bapiquanfin2.

append t_bapieket_tab.

ENDIF.

endloop.

Sort t_bapieket_tab by po_item.

sort t_bapimepoitem_tab1 by po_item.

sort t_bapimepoitemx_tab by po_item.

loop at t_bapieket_tab.

move: t_bapieket_tab-po_item to t_bapiposchedule-po_item,

t_bapieket_tab-serial_no to t_bapiposchedule-sched_line,

t_bapieket_tab-quantity to t_bapiposchedule-quantity,

t_bapieket_tab-preq_no to t_bapiposchedule-preq_no,

t_bapieket_tab-preq_item to t_bapiposchedule-preq_item.

if t_bapieket_tab-quantity = 0.

t_bapiposchedule-delete_ind = 'X'.

endif.

append t_bapiposchedule.

move: t_bapieket_tab-po_item to t_bapiposchedulex-po_item,

t_bapieket_tab-serial_no to t_bapiposchedulex-sched_line.

t_bapiposchedulex-po_itemx = 'X'.

t_bapiposchedulex-sched_linex = 'X'.

if t_bapieket_tab-quantity = 0.

t_bapiposchedulex-delete_ind = 'X'.

elseif t_bapieket_tab-quantity <> 0.

t_bapiposchedulex-quantity = 'X'.

endif.

clear: w_ebelp.

select single ebelp from ekpo

into w_ebelp

where ebeln = t_zmmpo_amend_tab-ebeln and

ebelp = t_bapieket_tab-po_item.

if w_ebelp is initial.

t_bapiposchedulex-preq_no = 'X'.

t_bapiposchedulex-preq_item = 'X'.

endif.

append t_bapiposchedulex.

clear: t_bapiposchedulex, t_bapiposchedule.

endloop.

ENDIF.

ENDLOOP.

***********end of new insertion**********************************************

CLEAR t_bapimepoitemdet_tab.

CLEAR v_bstmg.

ENDLOOP.

CALL FUNCTION 'BAPI_PO_CHANGE'

EXPORTING

purchaseorder = t_zmmpo_amend_tab-ebeln

TABLES

return = t_ret_tab

poitem = t_bapimepoitem_tab1

poitemx = t_bapimepoitemx_tab

*****************inserted by suganya-2006/06/27*************************

POSCHEDULE = t_bapiposchedule

POSCHEDULEX = t_bapiposchedulex

*****************end of insertion-suganya-2006/06/27********************

poaccount = t_bapimepoaccount_tab

poaccountx = t_bapimepoaccountx_tab

pocond = t_bapimepocond_tab

.

CLEAR v_flag.

LOOP AT t_ret_tab.

IF t_ret_tab-type = 'E'.

v_flag = 'X'.

WRITE:/2 t_zmmpo_amend_tab-ebeln,

15 t_ret_tab-type,

25 t_ret_tab-message.

ENDIF.

AT LAST.

IF v_flag <> 'X'.

UPDATE zmmpoamend FROM TABLE t_zmmpo_amend_tab1.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

WRITE:/2 'PO ',5 t_zmmpo_amend_tab-ebeln,

16 ' changed succesfully'.

ENDIF.

ENDAT.

ENDLOOP.

CLEAR t_ret_tab.

REFRESH t_ret_tab.

CLEAR t_bapimepocond_tab.

REFRESH t_bapimepocond_tab.

CLEAR t_zmmpo_amend_tab1.

REFRESH t_zmmpo_amend_tab1.

CLEAR t_bapimepoitem_tab.

REFRESH t_bapimepoitem_tab.

CLEAR t_bapimepoitemdet_tab.

REFRESH t_bapimepoitemdet_tab.

CLEAR t_bapimepoitem_tab1.

REFRESH t_bapimepoitem_tab1.

CLEAR t_bapimepoitemx_tab.

REFRESH t_bapimepoitemx_tab.

CLEAR t_bapimepoaccount_tab.

REFRESH t_bapimepoaccount_tab.

CLEAR t_bapimepoaccountdet_tab.

REFRESH t_bapimepoaccountdet_tab.

CLEAR t_bapimepoaccountx_tab.

REFRESH t_bapimepoaccountx_tab.

ENDAT.

ENDLOOP.

ENDIF.

                                • End of PO Amendment****************

Regrads,

Suganya Jayabalan

Read only

0 Likes
3,311

I'm bit confused with your code. I could see table <i>t_bapieket_tab</i> appending while looping the same table itself. This should not happen. Just check the validity of that quantity logic written !

I can say that the BAPI structure is fine, The problem can be with the data you manipulate and feed to that BAPI structures. There is a possibility that, you are feeding wrong data.

I cannont execute your program as you are using some custom tables. You can:

1) Put a break-point in PO BAPI and see the data which you are passing to it. See whether valid mapping ratio is there with data. I mean, the PO item <i>vs</i> the PR items and the schedule items.

If you again feel that the data is correct, pick up all the data exactly as you feed it to BAPI and then Go to ME22 transaction and apply it manualy. Then you will be able to understand the correct data which needs to passed to BAPI for your requirement.

Let me know if you have any questions.

Rgds,

TM.

Please mark points if helpful.

Read only

0 Likes
3,311

Hai Thomas,

I tried as u said, it is showing an error:

210000001 E Item 00020 does not exist

wen i used the same data in ME22N, it is going correctly.

These are the data feeded into the bapi.

poitem-po_item = '00010'.

poitem-short_text = 'Circuit breaker trial'.

poitem-material = 'IN004'.

poitem-plant = '0610'.

poitem-trackingno = '123'.

poitem-info_rec = '5300000420'.

poitem-quantity = 10.

poitem-po_unit_iso = 'PCE'.

poitem-orderpr_un = 'PC'.

poitem-orderpr_un_iso = 'PCE'.

poitem-conv_num1 = 1.

poitem-conv_den1 = 1.

poitem-net_price = 10.

poitem-price_unit = 1.

poitem-info_upd = 'B'.

poitem-prnt_price = 'X'.

poitem-gr_ind = 'X'.

poitem-ir_ind = 'X'.

poitem-weightunit = 'KG'.

poitem-weightunit_iso = 'KGM'.

poitem-cmmt_item = '173001'.

poitem-price_date = '20060519'.

poitem-preq_no = '0010002902'.

poitem-preq_item = '00010'.

poitem-cmmt_item_long = '173001'.

poitem-gr_basediv = ' '.

append poitem.

poitem-po_item = '00020'.

poitem-short_text = 'Circuit breaker trial'.

poitem-material = 'IN004'.

poitem-plant = '0610'.

poitem-trackingno = '123'.

poitem-info_rec = '5300000420'.

poitem-quantity = 290.

poitem-po_unit_iso = 'PCE'.

poitem-orderpr_un = 'PC'.

poitem-orderpr_un_iso = 'PCE'.

poitem-conv_num1 = 1.

poitem-conv_den1 = 1.

poitem-net_price = 10.

poitem-price_unit = 1.

poitem-info_upd = 'B'.

poitem-prnt_price = 'X'.

poitem-gr_ind = 'X'.

poitem-ir_ind = 'X'.

poitem-weightunit = 'KG'.

poitem-weightunit_iso = 'KGM'.

poitem-cmmt_item = '173001'.

poitem-price_date = '20060519'.

poitem-preq_no = '0010002902'.

poitem-preq_item = '00010'.

poitem-cmmt_item_long = '173001'.

poitem-gr_basediv = 'X'.

append poitem.

poitemx-po_item = '00010'.

poitemx-quantity = 'X'.

poitemx-gr_basediv = 'X'.

append poitemx.

poitemx-po_item = '00020'.

poitemx-material = 'X'.

poitemx-plant = 'X'.

poitemx-quantity = 'X'.

poitemx-po_unit = 'X'.

poitemx-preq_no = 'X'.

poitemx-preq_item = 'X'.

append poitemx.

poschedule-po_item = '00010'.

poschedule-sched_line = '0001'.

poschedule-quantity = 10.

poschedule-preq_no = '0010002902'.

poschedule-preq_item = '00010'.

append poschedule.

poschedule-po_item = '00010'.

poschedule-sched_line = '0002'.

poschedule-quantity = 0.

poschedule-preq_no = '0010002903'.

poschedule-preq_item = '00010'.

poschedule-delete_ind = 'X'.

append poschedule.

poschedule-po_item = '00020'.

poschedule-sched_line = '0001'.

poschedule-quantity = 90.

poschedule-preq_no = '0010002902'.

poschedule-preq_item = '00010'.

append poschedule.

poschedule-po_item = '00020'.

poschedule-sched_line = '0002'.

poschedule-quantity = 200.

poschedule-preq_no = '0010002903'.

poschedule-preq_item = '00010'.

append poschedule.

poschedulex-po_item = '00010'.

poschedulex-sched_line = '0001'.

poschedulex-po_itemx = 'X'.

poschedulex-sched_linex = 'X'.

poschedulex-quantity = 'X'.

append poschedulex.

poschedulex-po_item = '00010'.

poschedulex-sched_line = '0002'.

poschedulex-po_itemx = 'X'.

poschedulex-sched_linex = 'X'.

poschedulex-delete_ind = 'X'.

append poschedulex.

poschedulex-po_item = '00020'.

poschedulex-sched_line = '0001'.

poschedulex-po_itemx = 'X'.

poschedulex-sched_linex = 'X'.

poschedulex-quantity = 'X'.

poschedulex-preq_no = 'X'.

poschedulex-preq_item = 'X'.

append poschedulex.

poschedulex-po_item = '00020'.

poschedulex-sched_line = '0002'.

poschedulex-po_itemx = 'X'.

poschedulex-sched_linex = 'X'.

poschedulex-quantity = 'X'.

poschedulex-preq_no = 'X'.

poschedulex-preq_item = 'X'.

append poschedulex.

pocond-itm_number = '000010'.

pocond-cond_type = 'ZVCD'.

pocond-cond_value = '1000'.

pocond-currency = 'INR'.

append pocond.

pocond-itm_number = '000010'.

pocond-cond_type = 'ZVCV'.

pocond-cond_value = '100'.

pocond-currency = 'INR'.

append pocond.

pocond-itm_number = '000010'.

pocond-cond_type = 'ZVCE'.

pocond-cond_value = '2'.

pocond-currency = 'INR'.

append pocond.

pocond-itm_number = '000010'.

pocond-cond_type = 'ZVFI'.

pocond-cond_value = '120'.

pocond-currency = 'INR'.

append pocond.

pocond-itm_number = '000010'.

pocond-cond_type = 'ZVAC'.

pocond-cond_value = '300'.

pocond-currency = 'INR'.

append pocond.

pocond-itm_number = '000010'.

pocond-cond_type = 'ZPIN'.

pocond-cond_value = '0.2'.

pocond-currency = '%'.

append pocond.

pocond-itm_number = '000010'.

pocond-cond_type = 'ZPCL'.

pocond-cond_value = '0.5'.

pocond-currency = '%'.

append pocond.

I have changed the appending logic in t_bapieket_tab table. i inserted in a new internal table.

Regrads,

Suganya Jayabalan.

Read only

0 Likes
3,311

Hai frnds,

I got the solution for this issue by my own. I have to apply sap note for this issue. Thanks a lot for the replies.

Regrads,

Suganya.J

Read only

Former Member
0 Likes
3,311

Hi Suganya,

I am also having the same problem while creating more than one delivery schedule line items.

I found one OSS note 973156, while implementing this note through SNOTE, it is suggesting other OSS notes also. I could implement all other notes except this note and other note 765494, which is mandatory for 973156 seems because when try to implement 973156, it is proposing 765494 also. The note 765494 has manual corrections, when try to do manual corrections, the referring structures for parameters are not exist, so could not .

Could you please tell me the OSS note which you used to solve this issue.

Thanks & Regards

Hema

Read only

0 Likes
3,311

Hi Hema,

got the solution? <b>Note: 662716, 666888</b> is the note i used. Correction note: 618136, 592617.

regrads,

suganya.j