‎2007 Apr 04 4:33 AM
Hi,
Does anyone know how this BAPI populates the field POSCHEDULE-DELIVERY_DATE? Is there a way for me to customize its behavior?
Thanks!
‎2007 Apr 04 4:43 AM
Chan,
To populate check this Prog...
data : ITAB(100) occurs 0 with header line.
data : header like bapiekkoc OCCURS 0 WITH HEADER LINE.
data : items like bapiekpoc occurs 0 with header line.
data : schls like bapieket occurs 0 with header line.
data : ret like bapireturn occurs 0 with HEADER line.
data : po_num like bapiekkoc-PO_NUMBER.
CALL FUNCTION 'UPLOAD'
EXPORTING
FILENAME = 'C:\Documents and Settings\Administrator\Desktop\po.txt'
FILETYPE = 'ASC'
TABLES
DATA_TAB = ITAB .
LOOP AT ITAB.
IF ITAB+0(1) = 'H'.
IF SY-TABIX <> 1.
PERFORM CALL_BAPI.
ENDIF.
PERFORM FILL_HEADER.
ELSEIF ITAB+0(1) = 'I'.
PERFORM FILL_ITEMS.
ELSE.
PERFORM FILL_SCHLS.
ENDIF.
ENDLOOP.
PERFORM CALL_BAPI.
COMMIT WORK.
write : / 'po : ', po_num color 3.
loop at ret.
write 😕 ret.
endloop.
&----
*& Form CALL_BAPI
&----
FORM CALL_BAPI.
CALL FUNCTION 'BAPI_PO_CREATE'
EXPORTING
PO_HEADER = header
IMPORTING
PURCHASEORDER = po_num
TABLES
PO_ITEMS = items
PO_ITEM_SCHEDULES = schls
return = ret.
ENDFORM. " CALL_BAPI
&----
*& Form FILL_HEADER
&----
FORM FILL_HEADER.
HEADER-VENDOR = ITAB+1(10).
HEADER-PURCH_ORG = ITAB+11(4).
HEADER-PUR_GROUP = ITAB+15(3).
HEADER-SUPPL_PLNT = ITAB+18(4).
HEADER-DOC_TYPE = ITAB+22(2).
ENDFORM. " FILL_HEADER
&----
*& Form FILL_ITEMS
&----
FORM FILL_ITEMS.
ITEMS-MATERIAL = ITAB+1(18).
ITEMS-DISP_QUAN = ITAB+19(10).
ITEMS-NET_PRICE = ITAB+29(23).
APPEND ITEMS.
CLEAR ITEMS.
ENDFORM. " FILL_ITEMS
&----
*& Form FILL_SCHLS
&----
FORM FILL_SCHLS.
SCHLS-DELIV_DATE = ITAB+1(8).
SCHLS-QUANTITY = ITAB+9(13).
APPEND SCHLS.
CLEAR SCHLS.
ENDFORM. " FILL_SCHLS
Pls.reward if helpful...
‎2007 Apr 04 4:46 AM
hi winnie
please be sure to fill in appropriate fields in the 'X' tables as well. For the schedule line you must fill in POSCHEDULEX table.
be also sure to specify DEL_DATCAT_EXT field (could be 'D') and than DELIVERY_DATE must be in the DD/MM/YYYY format.
Try to fill this fields to:
poschedule-delivery_date = record_det-eeind_010.
poschedulex-delivery_date = 'X'.
poschedule-stat_date = record_det-eeind_010.
poschedulex-stat_date = 'X'.
poschedule-po_date = record_det-eeind_010.
poschedulex-po_date = 'X'.
fill in the PO_ITEM, SCHED_LINE with some values on the POSCHEDULE structure and filled the same values on the POSCHEDULEX structure See below.
v_schdule_line = v_schdule_line + 1.
v_poitem = v_poitem + 1.
poschedule-po_item = v_poitem * 10.
poschedule-sched_line = v_schdule_line.
poschedule-delivery_date = <DATE>.
append poschedule.
clear poschedule.
*--Fill X structures
poschedulex-po_item = v_poitem * 10.
poschedulex-sched_line = v_schdule_line.
poschedulex-po_itemx = 'X'.
poschedulex-delivery_date = 'X'.
poschedulex-sched_linex = 'X'.
append poschedulex.
clear poschedulex.
Your PO item numbers on the POITEM, POSCHEDULE and POSCHEDULEX structures should be same for the same item and the schedule line number should be the same on POSCHEDULE and the corresponding POSCHEDULEX structures.
Even if your po line item and schedule line item numbers are internally assigned, you need to do this.
try this link for a sample code
http://apolemia.blogspot.com/2005/06/create-purchase-order-with.html
regards
navjot
‎2007 Apr 04 4:49 AM
Hi,
I do know how to fill in the delivery dates. I'm just wondering why the BAPI seems to output a different date from what i've entered. It seems that its computing the delivery date based on the planned delivery time (info record) indicated in the article master (MM43) - Purchasing tab.
‎2007 Apr 04 5:39 AM
have to done it manually ? which date it is taking ? i think may be code code is overwritting ur delivery date ?
Regards
Prabhu