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 Problem

Former Member
0 Likes
413

REPORT zbapi_create_po .

&----


*DATA DECLARATION

CONSTANTS : c_x VALUE 'X'.

*Structures to hold PO header data

DATA : header LIKE bapimepoheader ,

headerx LIKE bapimepoheaderx .

*Internal Tables to hold PO ITEM DATA

DATA : item LIKE bapimepoitem OCCURS 0 WITH HEADER LINE,

itemx LIKE bapimepoitemx OCCURS 0 WITH HEADER LINE,

*Internal table to hold messages from BAPI call

return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.

DATA : w_header(40) VALUE 'PO Header'.

DATA : ws_langu LIKE sy-langu.

*text-001 = 'PO Header' - define as text element

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

PARAMETERS : company LIKE header-comp_code DEFAULT '1000' ,

doctyp LIKE header-doc_type DEFAULT 'NB' ,

cdate LIKE header-creat_date DEFAULT sy-datum ,

vendor LIKE header-vendor DEFAULT '1005',

pur_org LIKE header-purch_org DEFAULT '1000' ,

pur_grp LIKE header-pur_group DEFAULT '026' .

SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.

PARAMETERS : item_num LIKE item-po_item DEFAULT '00010',

material LIKE item-material DEFAULT 'DPC1017' ,

plant LIKE item-plant DEFAULT '1200' ,

quantity LIKE item-quantity DEFAULT 100.

SELECTION-SCREEN END OF BLOCK b2.

&----


START-OF-SELECTION.

&----


*DATA POPULATION

&----


ws_langu = sy-langu. "Language variable

*POPULATE HEADER DATA FOR PO

header-comp_code = company .

header-doc_type = doctyp .

header-creat_date = cdate .

header-vendor = vendor .

header-langu = ws_langu .

header-purch_org = pur_org .

header-pur_group = pur_grp .

&----


*POPULATE HEADER FLAG.

&----


headerx-comp_code = c_x.

headerx-doc_type = c_x.

headerx-creat_date = c_x.

headerx-vendor = c_x.

headerx-langu = c_x.

headerx-purch_org = c_x.

headerx-pur_group = c_x.

headerx-doc_date = c_x.

&----


*POPULATE ITEM DATA.

&----


item-po_item = item_num.

item-material = material.

item-plant = plant.

item-quantity = quantity.

APPEND item.

&----


*POPULATE ITEM FLAG TABLE

&----


itemx-po_item = item_num.

itemx-material = c_x.

itemx-plant = c_x .

itemx-stge_loc = c_x .

itemx-quantity = c_x .

itemx-tax_code = c_x .

itemx-item_cat = c_x .

itemx-acctasscat = c_x .

APPEND itemx.

&----


*BAPI CALL

&----


CALL FUNCTION 'BAPI_PO_CREATE1'

EXPORTING

poheader = header

poheaderx = headerx

  • POADDRVENDOR =

  • TESTRUN =

  • IMPORTING

  • EXPPURCHASEORDER =

  • EXPHEADER =

  • EXPPOEXPIMPHEADER =

TABLES

return = return

poitem = item

poitemx = itemx.

&----


*Confirm the document creation by calling database COMMIT

&----


CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'

  • IMPORTING

  • RETURN =

.

END-OF-SELECTION.

&----


*Output the messages returned from BAPI call

&----


LOOP AT return.

WRITE / return-message.

ENDLOOP.

____________________________________________________________________

I am getting this message, can u give me any ideas, where is the problem in code ?

<b>Creation of PO unsuccessful

PO Header data Still faulty

Purchase Order date is in the past

For the K4 fiscal year variant, no peroid is defined for 00.00.0000</b>

points for sure

Thanks in Advance

Vijaya

2 REPLIES 2
Read only

Former Member
0 Likes
378

Try by passign doc_date.

header-pur_group = sy-datum.

Read only

Former Member
0 Likes
378

header-doc_date = sy-datum.