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

using BAPI_REQUISITION_CREATE

Former Member
0 Likes
463

hi all,

please tell me how to upload data using BAPI_REQUISITION_CREATE

send me coding to understand myself .plz don't send link

Thanks in advance.

gupt

1 REPLY 1
Read only

Former Member
0 Likes
312


REPORT ZV1_BAPI_PR .
data:wa_eban like eban.
DATA: BEGIN OF itab OCCURS 0,
bsart(4),

."Purchase requisition document type
werks(4),

Plant
txz01(40),

."Short text
menge(13),

."Purchase requisition quantity
meins(3),

."Purchase requisition unit of measure
eeind(10),

."Item delivery date
wgbez(9),

."Material Group
name1(4),

."Plant
ekgrp(3),

."Purchasing Group
afnam(12),

."Name of requisitioner/requester
bednr(10),

."Requirement Tracking Number
knttp(1),

."Account assignment category
sakto(10),

."G/L Account Number
ps_posid(8),

."Work Breakdown Structure Element (WBS Element)
editor(132),

."Text line
END OF itab.

DATA: itab_bapiebanc LIKE bapiebanc OCCURS 0 WITH HEADER LINE.
DATA: itab_bapiebkn LIKE bapiebkn OCCURS 0 WITH HEADER LINE.
DATA: itab_bapiebantx LIKE bapiebantx OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF errmsg OCCURS 10.
INCLUDE STRUCTURE bapiret2.
DATA: END OF errmsg.
DATA: errflag.

select single * from eban
into wa_eban.

if sy-subrc = 0.

move-corresponding wa_eban to itab.
append itab.
clear itab.
endif.
*CALL FUNCTION 'UPLOAD'

EXPORTING
filename = 'C:\Documents and Settings\sap\Desktop\New Text Document (2).txt'
filetype = 'DAT'
TABLES
data_tab = itab.
*

.
*if sy-subrc 0.

message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
exit.
*endif.

LOOP AT itab.
itab_bapiebanc-doc_type = itab-bsart.
itab_bapiebanc-short_text = itab-txz01.
itab_bapiebanc-quantity = itab-menge.
itab_bapiebanc-unit = itab-meins.

if not itab-eeind is initial.
itab_bapiebanc-deliv_date = itab-eeind.
else.
itab_bapiebanc-deliv_date = sy-datum + 30.
endif.

itab_bapiebanc-plant = itab-werks.
itab_bapiebanc-pur_group = itab-ekgrp.
itab_bapiebanc-preq_name = itab-afnam.
itab_bapiebanc-trackingno = itab-bednr.
itab_bapiebanc-mat_grp = itab-wgbez.
itab_bapiebanc-acctasscat = itab-knttp.
itab_bapiebanc-acctasscat = 'A'.
itab_bapiebkn-g_l_acct = itab-sakto.
itab_bapiebkn-wbs_elem = itab-ps_posid.

itab_bapiebantx-text_line = itab-editor.
itab_bapiebantx-text_line = 'Test for Purchase requisiton'.
APPEND itab_bapiebkn.
APPEND itab_bapiebanc.
APPEND itab_bapiebantx.
ENDLOOP.
*
CALL FUNCTION 'BAPI_REQUISITION_CREATE'
TABLES
requisition_items = itab_bapiebanc
requisition_account_assignment = itab_bapiebkn
requisition_item_text = itab_bapiebantx
return = errmsg.

LOOP AT errmsg.
IF errmsg-type EQ 'E'.
WRITE:/'Error in function', errmsg-message.
errflag = 'X'.
ELSE.
WRITE:/ errmsg-message.
ENDIF.
ENDLOOP.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
*
*loop at itab_bapiebanc.
*write:/ itab_bapiebanc-doc_type,

itab_bapiebanc-short_text,
itab_bapiebanc-quantity,
itab_bapiebanc-unit ,
itab_bapiebanc-deliv_date,
itab_bapiebanc-plant,
itab_bapiebanc-pur_group,
itab_bapiebanc-preq_name,
itab_bapiebanc-trackingno,
itab_bapiebanc-mat_grp,
100 itab_bapiebanc-acctasscat.
*
*endloop.
*
*loop at itab_bapiebkn.

write:/ itab_bapiebkn-g_l_acct,
itab_bapiebkn-wbs_elem.
*
*endloop.
**
*
*loop at itab_bapiebantx.
*write:/ itab_bapiebantx-text_line.
*endloop.