Me21n Bdc
Hello Expert i am making a bdc for ME21n, to make a purchase order net price is compulsary for material
or you can say m21n has two subscreen/table control,
How Can i Handle it
Hi,
if user is directly using the transaction ME21N then you can use the the exit method.
if you are trying to create the PO in the background by uploading the PO details using the text or excel sheet then you can use the BAPI BAPI_PO_CRATE1 to create the PO.
you can check the data present in the file in the amount field before passing the data to the BAPI and if it is not populated pass the error message on the screen.
Similar Messages
-
Hi All,
while recording( in ME21) atlast im gettin an error like netprice is grtr than 0, eventhough netprice is positive value only,
while using me21n, cant craete prog, dunno why,
im getin hectic with this one,
I need code for ME21 / ME21N (purchase order create),
plz anyone help me,
thanks in advance,
hema.phi
check this code
report zgmimm_me21 no standard page heading line-size 255.
tables: t100.
type-pools: truxs.
types: begin of i_upload,
lifnr like ekko-lifnr, "Vendor Number
bukrs like ekko-bukrs, "Order type
bedat like ekko-bedat, "Purchase Order Date
ekorg like ekko-ekorg, "Purchasing organization
ausnr like ekko-ausnr, "Purchase order
ekgrp like ekko-ekgrp, "Purchasing group
eddat like ekko-bedat, "Delivery date
werks like ekpo-werks, "Plant
lgort like ekpo-lgort, "Storage location
zterm like ekko-zterm, "Payment terms
ematn like ekpo-ematn, "Material
menge like ekpo-menge, "PO Quantity
lewed like ekpo-lewed, "Latest GR Date
end of i_upload.
data: begin of i_input occurs 0,
pbg(10) type c,
bldat(07) type c, "001
BLDAT like BKPF-BUDAT,
hkont(10) type c,
kostl(10) type c,
wrbtr(11) type c,
dbcrflag(01) type c,
sgtxt(32) type c,
end of i_input.
data: v_counter(2) type n.
data: v_mod type i.
data: v_ebelp like ekpo-ebelp.
data: v_fname(132) type c.
data: v_fname1(132) type c.
data: v_tabix like sy-tabix.
data : ws_text(200) type c.
data : wa_mag(1).
data: begin of int_msg occurs 0,
cnt type i,
massage(1) type c,
text(200) type c,
end of int_msg.
data : begin of i_final occurs 0,
lifnr like ekko-lifnr, "Vendor Number
bukrs like ekko-bukrs, "Order type
bedat(10),
ekorg like ekko-ekorg, "Purchasing organization
ausnr like ekko-ausnr, "Purchase order
ekgrp like ekko-ekgrp, "Purchasing group
eddat(10),
werks like ekpo-werks, "Plant
lgort like ekpo-lgort, "Storage location
zterm like ekko-zterm, "Payment terms
ematn like ekpo-ematn, "Material
menge type char15, "PO Quantity
lewed(10),
TAX_CODE type mwskz,
GR_BASEDIV,
end of i_final.
data: it_datatab type standard table of i_upload,
wa_datatab type i_upload.
data: it_raw type truxs_t_text_data.
data: begin of bdcdata occurs 0.
include structure bdcdata.
data: end of bdcdata.
data: begin of messtab occurs 0.
include structure bdcmsgcoll.
data: end of messtab.
data: begin of t_input occurs 0.
include structure i_input.
data: end of t_input.
data: begin of i_local_output occurs 0,
text(2800) type c,
end of i_local_output.
data: begin of i_error occurs 0.
include structure i_input.
data: text(50) type c.
data: end of i_error.
data : _datum1(10).
data : t_datum1(10).
data: msgno like sy-msgno,
msgid like sy-msgid,
msgty like sy-msgty,
message like message.
*Data : TEXT(50) Type c value 'File Shoud be in Excel Format'.
data: wa_head type bapimepoheader,
wa_headx type bapimepoheaderx,
i_return type bapiret2 occurs 0 with header line,
i_item type bapimepoitem occurs 0 with header line,
i_itemx type bapimepoitemx occurs 0 with header line,
i_sch type bapimeposchedule occurs 0 with header line,
i_schx type bapimeposchedulx occurs 0 with header line.
SELECTION SCREEN
parameters: p_file type rlgrap-filename obligatory modif id app.
Write : /3 Text.
START OF SELECTION
at selection-screen on value-request for p_file.
call function 'F4_FILENAME'
exporting
field_name = 'P_FILE'
importing
file_name = p_file.
start-of-selection.
perform data_from_excel_to_sap.
perform pass_data_to_final_int_tab.
perform fill_bdc_data.
perform fill_bapi_parameters.
perform call_po_create_bapi.
*& Form DATA_FROM_EXCEL_TO
text
--> p1 text
<-- p2 text
form data_from_excel_to_sap.
call function 'TEXT_CONVERT_XLS_TO_SAP'
exporting
I_FIELD_SEPERATOR =
i_line_header = 'X'
i_tab_raw_data = it_raw " WORK TABLE
i_filename = p_file
tables
i_tab_converted_data = it_datatab[] "ACTUAL DATA
exceptions
conversion_failed = 1
others = 2.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endform. " DATA_FROM_EXCEL_TO
*& Form PASS_DATA_TO_FINAL_INTERNAL_TA
text
--> p1 text
<-- p2 text
form pass_data_to_final_int_tab.
loop at it_datatab into wa_datatab.
move wa_datatab-lifnr to i_final-lifnr. "Vendor Number
move wa_datatab-bukrs to i_final-bukrs. "Order type
move wa_datatab-bedat to i_final-bedat. "Purchase Order Date
concatenate i_final-bedat6(2) '.' i_final-bedat4(2) '.20'
i_final-bedat+2(2) into _datum1.
i_final-bedat = _datum1.
move wa_datatab-ekorg to i_final-ekorg. "Purchasing organization
move wa_datatab-ausnr to i_final-ausnr. "Purchase order
move wa_datatab-ekgrp to i_final-ekgrp. "Purchasing group
move wa_datatab-eddat to i_final-eddat. "Delivery date
concatenate i_final-eddat6(2) '.' i_final-eddat4(2) '.20'
i_final-eddat+2(2) into _datum1.
i_final-eddat = _datum1.
move wa_datatab-werks to i_final-werks. "Plant
move wa_datatab-lgort to i_final-lgort. "Storage location
move wa_datatab-zterm to i_final-zterm. "Payment terms
move wa_datatab-ematn to i_final-ematn. "Material
move wa_datatab-menge to i_final-menge. "PO Quantity
move wa_datatab-lewed to i_final-lewed. "Latest GR Date
***Value Hard coaded considering this Program is only for Import.
I_FINAL-TAX_CODE = 'V0'.
I_FINAL-GR_BASEDIV = ' '.
concatenate i_final-lewed6(2) '.' i_final-lewed4(2) '.20'
i_final-lewed+2(2) into _datum1.
i_final-lewed = _datum1.
append i_final.
endloop.
endform. " PASS_DATA_TO_FINAL_INTERNAL_TA
*& Form FILL_BDC_DATA
text
--> p1 text
<-- p2 text
form fill_bdc_data.
read table i_final index 1.
perform f0510_bdcdata using :
'X' 'SAPMM06E' '0100',
' ' 'BDC_CURSOR' 'RM06E-MATKL',
' ' 'BDC_OKCODE' '=KOPF',
' ' 'EKKO-LIFNR' i_final-lifnr,
' ' 'RM06E-BSART' i_final-bukrs,
' ' 'RM06E-BEDAT' i_final-bedat,
' ' 'RM06E-BSTNR' i_final-ausnr,
' ' 'EKKO-EKORG' i_final-ekorg,
' ' 'EKKO-EKGRP' i_final-ekgrp,
' ' 'RM06E-EEIND' i_final-eddat,
' ' 'RM06E-LPEIN' 'T',
' ' 'RM06E-WERKS' i_final-werks,
' ' 'RM06E-LGORT' i_final-lgort.
perform f0510_bdcdata using :
'X' 'SAPMM06E' '0101',
' ' 'BDC_OKCODE' '=AB',
' ' 'EKKO-ZTERM' i_final-zterm.
move: '01' to v_counter.
loop at i_final.
move: sy-tabix to v_tabix.
concatenate 'EKPO-EMATN(' v_counter ')' into v_fname.
concatenate 'EKPO-MENGE(' v_counter ')' into v_fname1.
perform f0510_bdcdata using :
'X' 'SAPMM06E' '0120',
' ' 'BDC_OKCODE' '=DETZ',
' ' 'RM06E-EBELP' '5',
' ' v_fname i_final-ematn,
' ' v_fname1 i_final-menge.
perform f0510_bdcdata using :
'X' 'SAPMM06E' '0112',
' ' 'BDC_CURSOR' 'EKPO-LEWED',
' ' 'BDC_OKCODE' '/00',
' ' 'EKPO-LEWED' i_final-lewed,
' ' 'EKPO-PRDAT' i_final-bedat.
' ' 'EKPO-IPRKZ' 'D'.
v_mod = v_counter mod 5.
if v_mod eq 0.
clear v_ebelp.
move: v_tabix to v_ebelp.
perform f0510_bdcdata using :
'X' 'SAPMM06E' '0120',
' ' 'BDC_OKCODE' '/00',
' ' 'RM06E-EBELP' v_ebelp.
v_counter = '02'.
else.
v_counter = v_counter + 1.
endif.
endloop.
loop at i_final.
clear: v_fname.
v_counter = sy-tabix.
v_ebelp = sy-tabix.
concatenate 'RM06E-TCSELFLAG(' '01' ')' into v_fname.
perform f0510_bdcdata using :
'X' 'SAPMM06E' '0120',
' ' 'RM06E-EBELP' v_ebelp,
' ' 'BDC_OKCODE' '/00'.
perform f0510_bdcdata using :
'X' 'SAPMM06E' '0120',
' ' 'BDC_CURSOR' 'RM06E-BSTPO(01)',
' ' 'BDC_OKCODE' '=DETZ',
' ' 'RM06E-EBELP' v_ebelp,
' ' v_fname 'X'.
perform f0510_bdcdata using :
'X' 'SAPMM06E' '0112',
' ' 'BDC_CURSOR' 'EKPO-LEWED',
' ' 'BDC_OKCODE' '/00',
' ' 'EKPO-PLIFZ' '91',
' ' 'EKPO-GEWEI' 'KG',
' ' 'EKPO-PRDAT' i_final-bedat,
' ' 'EKPO-IPRKZ' 'D',
' ' 'EKPO-LEWED' i_final-lewed.
endloop.
perform f0510_bdcdata using :
'X' 'SAPMM06E' '0120',
' ' 'BDC_CURSOR' 'RM06E-BSTPO(10)',
' ' 'BDC_OKCODE' '=BU',
' ' 'RM06E-EBELP' '1'.
perform f0510_bdcdata using :
'X' 'SAPLSPO1' '0300',
' ' 'BDC_OKCODE' '=YES'.
call transaction 'ME21' using bdcdata messages into messtab
mode 'A' update 'S'.
perform f000_process_errors.
clear: bdcdata, messtab.
refresh: bdcdata, messtab.
loop at int_msg.
write:/ int_msg-text.
endloop.
endform. " FILL_BDC_DATA
*& Form F0510_BDCDATA
text
-->dynbegin text
-->name text
-->value text
form f0510_bdcdata using value(dynbegin)
value(name)
value(value).
if dynbegin = 'X'.
clear bdcdata.
move: name to bdcdata-program,
value to bdcdata-dynpro,
'X' to bdcdata-dynbegin.
append bdcdata.
else.
clear bdcdata.
move: name to bdcdata-fnam,
value to bdcdata-fval.
append bdcdata.
endif.
endform. " F0510_BDCDATA
*& Form F000_PROCESS_ERRORS
text
--> p1 text
<-- p2 text
form f000_process_errors.
loop at messtab.
clear t100.
select single * from t100 where sprsl = messtab-msgspra
and arbgb = messtab-msgid
and msgnr = messtab-msgnr.
ws_text = t100-text.
wa_mag = messtab-msgtyp.
if ws_text cs '&1'.
replace '&1' with messtab-msgv1 into ws_text.
replace '&2' with messtab-msgv2 into ws_text.
replace '&3' with messtab-msgv3 into ws_text.
replace '&4' with messtab-msgv4 into ws_text.
else.
replace '&' with messtab-msgv1 into ws_text.
replace '&' with messtab-msgv2 into ws_text.
replace '&' with messtab-msgv3 into ws_text.
replace '&' with messtab-msgv4 into ws_text.
endif.
condense ws_text.
move ws_text to int_msg-text.
move wa_mag to int_msg-massage.
append int_msg.
endloop.
delete int_msg where massage = 'W'.
endform. " F000_PROCESS_ERRORS
*& Form fill_bapi_parameters
Subroutine to fill BAPI Parameters
form fill_bapi_parameters.
clear: wa_head, wa_headx, i_return, i_item, i_itemx, i_sch, i_schx.
perform fill_bapi_header.
perform fill_bapi_items.
endform. " fill_bapi_parameters
*& Form fill_bapi_header
Subroutine to fill the bapi header
form fill_bapi_header.
read table i_final index 1.
check sy-subrc eq 0.
move: i_final-ausnr to wa_head-po_number,
i_final-bukrs to wa_head-doc_type,
i_final-zterm to wa_head-pmnttrms,
i_final-ekorg to wa_head-purch_org,
i_final-ekgrp to wa_head-pur_group,
'FOB' to wa_head-incoterms1,
'Free On Board' to wa_head-incoterms2.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = i_final-lifnr
importing
output = i_final-lifnr.
move: i_final-lifnr to wa_head-vendor.
concatenate i_final-bedat+6(4)
i_final-bedat+3(2)
i_final-bedat(2) into wa_head-doc_date.
move: 'X' to wa_headx-po_number,
'X' to wa_headx-doc_type,
'X' to wa_headx-vendor,
'X' to wa_headx-pmnttrms,
'X' to wa_headx-purch_org,
'X' to wa_headx-pur_group,
'X' to wa_headx-doc_date,
'X' to wa_headx-incoterms1,
'X' to wa_headx-incoterms2.
endform. " fill_bapi_header
*& Form fill_bapi_items
Subroutine to fill the bapi items
form fill_bapi_items.
loop at i_final.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = i_final-ematn
importing
output = i_final-ematn.
move: sy-tabix to i_item-po_item,
i_final-ematn to i_item-material,
i_final-werks to i_item-plant,
i_final-lgort to i_item-stge_loc,
i_final-menge to i_item-quantity.
I_ITEM-TAX_CODE = I_FINAL-TAX_CODE.
I_ITEM-GR_BASEDIV = I_FINAL-GR_BASEDIV.
concatenate i_final-lewed+6(4)
i_final-lewed+3(2)
i_final-lewed(2) into i_item-gr_to_date.
move: sy-tabix to i_itemx-po_item,
'X' to i_itemx-po_itemx,
'X' to i_itemx-material,
'X' to i_itemx-plant,
'X' to i_itemx-stge_loc,
'X' to i_itemx-quantity,
'X' to i_itemx-gr_to_date.
move: 'X' TO i_itemx-TAX_CODE ,
'X' TO i_itemx-GR_BASEDIV.
append: i_item, i_itemx.
move: sy-tabix to i_sch-po_item,
'0001' to i_sch-sched_line,
'D' to i_sch-del_datcat_ext.
i_final-menge to i_sch-quantity.
concatenate i_final-eddat(2)
i_final-eddat+3(2)
i_final-eddat+6(4) into i_sch-delivery_date.
move: sy-tabix to i_schx-po_item,
'0001' to i_schx-sched_line,
'X' to i_schx-po_itemx,
'X' to i_schx-sched_linex,
'X' to i_schx-quantity,
'X' to i_schx-delivery_date,
'X' to i_schx-del_datcat_ext.
append: i_sch, i_schx.
endloop.
endform. " fill_bapi_items
*& Form call_po_create_bapi
Subroutine to call PO CREATE BAPI
form call_po_create_bapi.
call function 'BAPI_PO_CREATE1'
exporting
poheader = wa_head
poheaderx = wa_headx
tables
return = i_return
poitem = i_item
poitemx = i_itemx
poschedule = i_sch
poschedulex = i_schx.
read table i_return with key type = 'S'
id = '06'
number = '017'.
if sy-subrc eq 0.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
write:/ i_return-message.
else.
delete i_return where type = 'S'.
delete i_return where type = 'I'.
delete i_return where type = 'W'.
write:/ 'Following Errors occured in PO Creation:'.
skip.
loop at i_return.
write:/ i_return-message.
endloop.
endif.
endform. " call_po_create_bapi
thanks
sitaram -
ME21N cannot run in the background - BDC
Hi all,
i had created a program using BDC to create PO via tcode, ME21N.
When i run my program online, nothing happens.
But when i schedule my program as batch job, the CNTRL_ERROR on exception error occurred.
I inform to my basis team. they insisted that ME21N BDC cannot run in batch job.
Pls kindly advice.
tks in advance to all those contribute.BDC for ME21N Transaction
using BDC for ME21N
Need BDC program for ME21n
Re: Creation of PO using BDC with ME21N - Urgent
Reward points.. -
Hello
I have one dout,
when i received the three quotations from different vendor,after the price comaprision one best vendor is selected for us,
is there any user exit is avialable for us to when we going to create the PO, system will automaticaly takes the that perticular vendor only.
because,
when corporate office is in Delhi, PO's are created from Bangalore, the Bangalore people doesnot know which vendor is at last seleted, (is there any option in POlevel where user can find that this vedor is selected from no of quotations and i have to use this vendor only in PO
how he come to know this is finalised qutation vendor)
plz share your knowledge.
regards
sapmanDear ,
Here' s another option, If you want to automatically create PO from the best price, you can make Z program that contain ME21 / ME21N BDC, then use PR and PR Item as selection, then when the program run, it will check all the quotation for the PR and check which is the best net price / unit and then the PO will created based on the winning quotation.Simple in users side, but more effort in technical
Regards,
w1n -
Creation of PO using BDC with ME21N - Urgent
Hi All,
My requirement is to create a Purchase Order using BDC. I'm using ME21N for BDC. I did recording and using that recording I wrote a program for BDC. BDC table is populated correctly, but while calling ME21N using call transaction, program is cuming back to the selection screen, without creating PO. And sy-subrc value after call transaction is '0'. Please let me know the problem.
Thanks in Advance.
Siva Sankar.Hi,
Put a break point after the call transaction statement(i.e, put break point on sy-subrc check)
and then check the message table.
if call transaction is suceessfull u will find a success messages in the I_messages table.
Regards,
Sriram -
hi gurus,
i want notes for creating materials and to create purchase order using bdc and to upload some datas using that recording from datas in note pad or any external file with screen shots. if any body sent to it ll be very useful to me...
thanks in advance
arunHi,
check the codes for mm01 and me21n.
mm01
report ZBHMAT no standard page heading line-size 255.
DATA:BEGIN OF ITAB OCCURS 0,
MATNR LIKE RMMG1-MATNR,
MBRSH LIKE RMMG1-MBRSH,
MTART LIKE RMMG1-MTART,
KZSEL LIKE MSICHTAUSW-KZSEL,
WERKS LIKE RMMG1-WERKS,
VKORG LIKE RMMG1-VKORG,
VTWEG LIKE RMMG1-VTWEG,
MAKTX LIKE MAKT-MAKTX,
MEINS LIKE MARA-MEINS,
SKTOF LIKE MVKE-SKTOF,
TAXKM LIKE MG03STEUER-TAXKM,
GEWEI LIKE MARA-GEWEI,
MTVFP LIKE MARC-MTVFP,
TRAGR LIKE MARA-TRAGR,
LADGR LIKE MARC-LADGR,
END OF ITAB.
DATA BDCTAB LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'C:/BHARAT/MAT.TXT'
FILETYPE = 'ASC'
TABLES
DATA_TAB = ITAB.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = 'MATERIAL'
KEEP = 'X'
USER = SY-UNAME
PROG = SY-CPROG.
LOOP AT ITAB.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'RMMG1-MATNR'
ITAB-MATNR.
perform bdc_field using 'RMMG1-MBRSH'
ITAB-MBRSH.
perform bdc_field using 'RMMG1-MTART'
ITAB-MTART.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-KZSEL(04)'.
perform bdc_field using 'MSICHTAUSW-KZSEL(04)'
ITAB-KZSEL.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_dynpro using 'SAPLMGMM' '0080'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-WERKS'.
perform bdc_field using 'RMMG1-WERKS'
ITAB-WERKS.
perform bdc_field using 'RMMG1-VKORG'
ITAB-VKORG.
perform bdc_field using 'RMMG1-VTWEG'
ITAB-VTWEG.
perform bdc_field using 'BDC_OKCODE'
'ENTR'.
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'BDC_CURSOR'
'MAKT-MAKTX'.
perform bdc_field using 'MAKT-MAKTX'
ITAB-MAKTX.
perform bdc_field using 'MARA-MEINS'
ITAB-MEINS.
perform bdc_field using 'MVKE-SKTOF'
ITAB-SKTOF.
perform bdc_field using 'MG03STEUER-TAXKM(01)'
ITAB-TAXKM.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPLMGMM' '4200'.
perform bdc_field using 'BDC_CURSOR'
'MAKT-MAKTX'.
perform bdc_field using 'MAKT-MAKTX'
ITAB-MAKTX.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'BDC_CURSOR'
'MAKT-MAKTX'.
perform bdc_field using 'MAKT-MAKTX'
ITAB-MAKTX.
perform bdc_field using 'MARA-MEINS'
ITAB-MEINS.
perform bdc_field using 'MVKE-SKTOF'
ITAB-SKTOF.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
perform bdc_dynpro using 'SAPLMGMM' '4000'.
perform bdc_field using 'BDC_CURSOR'
'MAKT-MAKTX'.
perform bdc_field using 'MAKT-MAKTX'
ITAB-MAKTX.
perform bdc_field using 'MARA-MEINS'
ITAB-MEINS.
perform bdc_field using 'MARA-GEWEI'
ITAB-GEWEI.
perform bdc_field using 'MARC-MTVFP'
ITAB-MTVFP.
perform bdc_field using 'MARA-TRAGR'
ITAB-TRAGR.
perform bdc_field using 'MARC-LADGR'
ITAB-LADGR.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'MM01'
TABLES
DYNPROTAB = BDCTAB.
REFRESH BDCTAB.
ENDLOOP.
CALL FUNCTION 'BDC_CLOSE_GROUP'.
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR BDCTAB.
BDCTAB-PROGRAM = PROGRAM.
BDCTAB-DYNPRO = DYNPRO.
BDCTAB-DYNBEGIN = 'X'.
APPEND BDCTAB.
ENDFORM.
FORM BDC_FIELD USING FNAM FVAL.
CLEAR BDCTAB.
BDCTAB-FNAM = FNAM.
BDCTAB-FVAL = FVAL.
APPEND BDCTAB.
ENDFORM.
me21n
report ZBH_PURORDER no standard page heading line-size 255.
PARAMETERS:P_FILE LIKE IBIPPARMS-PATH.
DATA FILENAME TYPE STRING.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = sy-cprog
dynpro_number = sy-dynnr
IMPORTING
file_name = P_FILE.
START-OF-SELECTION.
FILENAME = P_FILE.
DATA:BEGIN OF XTAB OCCURS 0,
TYP,
DES(255) TYPE C,
END OF XTAB.
DATA:BEGIN OF ITAB OCCURS 0,
SUPERFIELD LIKE MEPO_TOPLINE-SUPERFIELD,
EKORG LIKE MEPO1222-EKORG,
EKGRP LIKE MEPO1222-EKGRP,
BUKRS LIKE MEPO1222-BUKRS,
END OF ITAB.
DATA:BEGIN OF JTAB OCCURS 0,
N(4) TYPE C,
EMATN LIKE MEPO1211-EMATN,
MENGE(13) TYPE C,
NETPR(13) TYPE C,
NAME1 LIKE MEPO1211-NAME1,
END OF JTAB.
DATA:BDCTAB LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
DATA:DELIMITER VALUE '*'.
DATA A TYPE I.
DATA M(4) TYPE N.
DATA L_FNAM(30) TYPE C.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = FILENAME
FILETYPE = 'ASC'
TABLES
DATA_TAB = XTAB.
LOOP AT XTAB.
IF XTAB-TYP = 'H'.
SPLIT XTAB-DES AT DELIMITER INTO ITAB-SUPERFIELD ITAB-EKORG ITAB-EKGRP
ITAB-BUKRS.
JTAB-N = JTAB-N + 1.
APPEND ITAB.
ELSEIF XTAB-TYP = 'I'.
SPLIT XTAB-DES AT DELIMITER INTO JTAB-EMATN JTAB-MENGE JTAB-NETPR
JTAB-NAME1.
APPEND JTAB.
ENDIF.
ENDLOOP.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = 'PORDER'
KEEP = 'X'
USER = SY-UNAME.
LOOP AT ITAB.
A = SY-TABIX.
REFRESH BDCTAB.
perform bdc_dynpro using 'SAPLMEGUI' '0014'.
perform bdc_field using 'BDC_CURSOR'
'MEPO_TOPLINE-SUPERFIELD'.
perform bdc_field using 'MEPO_TOPLINE-BSART'
'NB'.
perform bdc_field using 'MEPO_TOPLINE-SUPERFIELD'
ITAB-SUPERFIELD.
perform bdc_field using 'MEPO_TOPLINE-BEDAT'
'09.02.2007'.
perform bdc_field using 'DYN_6000-LIST'
' 1'.
perform bdc_field using 'BDC_OKCODE'
'=MEV4000BUTTON'.
perform bdc_dynpro using 'SAPLMEGUI' '0014'.
perform bdc_field using 'MEPO_TOPLINE-BSART'
'NB'.
perform bdc_field using 'MEPO_TOPLINE-SUPERFIELD'
ITAB-SUPERFIELD.
perform bdc_field using 'MEPO_TOPLINE-BEDAT'
'09.02.2007'.
perform bdc_field using 'BDC_CURSOR'
'MEPO1222-EKORG'.
perform bdc_field using 'MEPO1222-EKORG'
ITAB-EKORG.
perform bdc_field using 'MEPO1222-EKGRP'
ITAB-EKGRP.
perform bdc_field using 'MEPO1222-BUKRS'
ITAB-BUKRS.
perform bdc_field using 'DYN_6000-LIST'
' 1'.
perform bdc_field using 'BDC_OKCODE'
'=MEV4001BUTTON'.
perform bdc_dynpro using 'SAPLMEGUI' '0014'.
perform bdc_field using 'MEPO_TOPLINE-BSART'
'NB'.
perform bdc_field using 'MEPO_TOPLINE-SUPERFIELD'
ITAB-SUPERFIELD.
perform bdc_field using 'MEPO_TOPLINE-BEDAT'
'09.02.2007'.
perform bdc_field using 'MEPO1222-EKORG'
ITAB-EKORG.
perform bdc_field using 'MEPO1222-EKGRP'
ITAB-EKGRP.
perform bdc_field using 'MEPO1222-BUKRS'
ITAB-BUKRS.
M = 1.
LOOP AT JTAB.
IF JTAB-N = A.
WRITE:/ JTAB.
CONCATENATE 'MEPO1211-EMATN(' M ')' INTO L_FNAM.
perform bdc_field using 'BDC_CURSOR'
L_FNAM.
perform bdc_field using L_FNAM
JTAB-EMATN.
CONCATENATE 'MEPO1211-MENGE(' M ')' INTO L_FNAM.
perform bdc_field using L_FNAM
JTAB-MENGE.
CONCATENATE 'MEPO1211-NETPR(' M ')' INTO L_FNAM.
perform bdc_field using L_FNAM
JTAB-NETPR.
CONCATENATE 'MEPO1211-NAME1(' M ')' INTO L_FNAM.
perform bdc_field using L_FNAM
JTAB-NAME1.
M = M + 1.
ENDIF.
ENDLOOP.
perform bdc_field using 'DYN_6000-LIST'
' 1'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPLMEGUI' '0014'.
perform bdc_field using 'MEPO_TOPLINE-BSART'
'NB'.
perform bdc_field using 'MEPO_TOPLINE-SUPERFIELD'
ITAB-SUPERFIELD.
perform bdc_field using 'MEPO_TOPLINE-BEDAT'
'09.02.2007'.
perform bdc_field using 'MEPO1222-EKORG'
ITAB-EKORG.
perform bdc_field using 'MEPO1222-EKGRP'
ITAB-EKGRP.
perform bdc_field using 'MEPO1222-BUKRS'
ITAB-BUKRS.
perform bdc_field using 'DYN_6000-LIST'
' 1'.
perform bdc_field using 'BDC_CURSOR'
'MEPO1319-MATKL'.
perform bdc_field using 'MEPO1319-SPINF'
'X'.
perform bdc_field using 'BDC_OKCODE'
'=MESAVE'.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'ME21N'
TABLES
DYNPROTAB = BDCTAB.
ENDLOOP.
CALL FUNCTION 'BDC_CLOSE_GROUP'.
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR BDCTAB.
BDCTAB-PROGRAM = PROGRAM.
BDCTAB-DYNPRO = DYNPRO.
BDCTAB-DYNBEGIN = 'X'.
APPEND BDCTAB.
ENDFORM.
FORM BDC_FIELD USING FNAM FVAL.
CLEAR BDCTAB.
BDCTAB-FNAM = FNAM.
BDCTAB-FVAL = FVAL.
APPEND BDCTAB.
ENDFORM.
FLAT FILE:
H1171611000001*1000
ICPU116000*1000
ILEY BOARD1010000*1000
IMOUSE66000*1000
H1171711000001*1000
ICPU580000*1000
H1171701000001*1000
IMOUSE33000*1000
ILEY BOARD1010000*1000
rgds,
bharat. -
Hi All,
I need to create a BDC program for the creation of purchase orders using tcode ME21n.
I have Header data & Item data to upload while creating the purchase order.
How to handle the uploading of header data & item data.
How should we code the program & how the flatfile should be designed.
Regards,
SudhirHi
Here I am giving you a sample code..where we need to create PO's from Z table...
Regarding the structure of the flat file, it is purely based on the client and the functional team.. they will know better which fields are to be filled. So, you have to sit with the functional guy and do the recording using SHDB tcode and then decide with the flat file.
*& Report ZZPO_BDC
REPORT ZZPO_BDC no standard page heading line-size 255.
tables: zzpo_staging.
DATA id type string..
DATA: fnam(20) type c,
matnr type bstmg.
data: quan(13) type c,
netpr(15) type c,
qty(13) type c,
gp(15) type c.
DATA idx type string.
data: i_bdcdata like bdcdata occurs 1 with header line,
i_msg like bdcmsgcoll occurs 1 with header line.
DATA W_STR type string.
DATA: IT_STAGING TYPE STANDARD TABLE OF ZZPO_STAGING WITH HEADER LINE,
ti_staging type standard table of zzpo_staging with header line,
KT_STAGING TYPE STANDARD TABLE OF ZZPO_STAGING WITH HEADER LINE.
*CALL FUNCTION 'BDC_OPEN_GROUP'
* EXPORTING
* CLIENT = SY-MANDT
* DEST = 'zzpo'
* GROUP = 'zzpo'
** HOLDDATE = FILLER8
* KEEP = 'X'
* USER = sy-uname
** RECORD = FILLER1
** PROG = SY-CPROG
** DCPFM = '%'
** DATFM = '%'
** IMPORTING
** QID =
** EXCEPTIONS
** CLIENT_INVALID = 1
** DESTINATION_INVALID = 2
** GROUP_INVALID = 3
** GROUP_IS_LOCKED = 4
** HOLDDATE_INVALID = 5
** INTERNAL_ERROR = 6
** QUEUE_ERROR = 7
** RUNNING = 8
** SYSTEM_LOCK_ERROR = 9
** USER_INVALID = 10
** OTHERS = 11
*IF SY-SUBRC <> 0.
** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
** WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*ENDIF.
start-of-selection.
*perform open_group.
SELECT * FROM ZZPO_STAGING INTO TABLE IT_STAGING.
select * from zzpo_staging into table ti_staging.
SELECT * fROM ZZPO_STAGING INTO TABLE KT_sTAGING.
delete adjacent duplicates from it_staging comparing vendor docdate.
loop at IT_STAGING.
perform bdc_dynpro using 'SAPMM06E' '0100'.
perform bdc_field using 'BDC_CURSOR'
'EKKO-EKGRP'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'EKKO-LIFNR'
IT_STAGING-vendor.
perform bdc_field using 'RM06E-BSART'
'NB'.
perform bdc_field using 'RM06E-BEDAT'
IT_STAGING-docdate.
perform bdc_field using 'EKKO-EKORG'
IT_STAGING-purorg.
perform bdc_field using 'EKKO-EKGRP'
IT_STAGING-purgrp.
perform bdc_field using 'RM06E-LPEIN'
'T'.
* endloop.
perform bdc_dynpro using 'SAPMM06E' '0120'.
perform bdc_field using 'BDC_CURSOR'
'RM06E-EPSTP(01)'.
perform bdc_field using 'BDC_OKCODE'
'=DETA'.
perform bdc_dynpro using 'SAPMM06E' '0120'.
perform bdc_field using 'BDC_CURSOR'
'EKPO-WERKS(01)'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
move 1 to id.
loop at TI_STAGING WHERE VENDOR = IT_STAGING-VENDOR AND DOCDATE = IT_STAGING-DOCDATE.
concatenate 'RM06E-EPSTP(0' id ')' into fnam.
perform bdc_field using fnam TI_STAGING-itmcategory.
concatenate 'EKPO-KNTTP(0' id ')' into fnam.
perform bdc_field using fnam TI_STAGING-accassignment.
concatenate 'EKPO-EMATN(0' id ')' into fnam.
perform bdc_field using fnam TI_STAGING-material.
concatenate 'EKPO-TXZ01(0' id ')' into fnam.
perform bdc_field using fnam TI_STAGING-shortxt.
quan = ti_staging-poqty.
concatenate 'EKPO-MENGE(0' id ')' into fnam.
perform bdc_field using fnam quan.
concatenate 'RM06E-EEIND(0' id ')' into fnam.
perform bdc_field using fnam TI_STAGING-deliverydate.
netpr = ti_staging-netpr.
concatenate 'EKPO-NETPR(0' id ')' into fnam.
perform bdc_field using fnam netpr.
concatenate 'EKPO-MATKL(0' id ')' into fnam.
perform bdc_field using fnam TI_STAGING-mategroup.
concatenate 'EKPO-WERKS(0' id ')' into fnam.
perform bdc_field using fnam TI_STAGING-plant.
ID = ID + 1.
ENDLOOP.
* perform bdc_dynpro using 'SAPMM06E' '0111'.
* perform bdc_field using 'BDC_CURSOR'
* 'EKPO-MENGE'.
* perform bdc_field using 'BDC_OKCODE'
* '/00'.
*perform bdc_field using 'EKPO-KNTTP'
* 'N'.
*perform bdc_field using 'EKPO-TXZ01'
* 'Office Supplies'.
*perform bdc_field using 'EKPO-MENGE'
* '2'.
* perform bdc_field using 'EKPO-SPINF'
* 'B'.
* perform bdc_field using 'EKPO-BPUMN'
* '1'.
* perform bdc_field using 'EKPO-BPUMZ'
* '1'.
* perform bdc_field using 'EKPO-PRSDR'
* 'X'.
*perform bdc_field using 'RM06E-EEIND'
* '06/24/2008'.
*perform bdc_field using 'RM06E-LPEIN'
* 'D'.
* perform bdc_field using 'EKPO-WEPOS'
* 'X'.
* perform bdc_field using 'EKPO-REPOS'
* 'X'.
loop at TI_STAGING where vendor = it_staging-vendor and docdate = it_staging-docdate.
perform bdc_dynpro using 'SAPMM06E' '0511'.
perform bdc_field using 'BDC_OKCODE'
'=ENTE'.
perform bdc_field using 'EKKN-SAKTO'
TI_STAGING-glaccount.
perform bdc_field using 'BDC_CURSOR'
'DKACB-FMORE'.
perform bdc_field using 'DKACB-FMORE'
'X'.
perform bdc_dynpro using 'SAPLKACB' '0002'.
perform bdc_field using 'BDC_CURSOR'
'COBL-VORNR'.
perform bdc_field using 'BDC_OKCODE'
'=ENTE'.
perform bdc_field using 'COBL-NPLNR'
TI_STAGING-networkid.
perform bdc_field using 'COBL-VORNR'
TI_STAGING-activity.
* perform bdc_dynpro using 'SAPMM06E' '0120'.
* perform bdc_field using 'BDC_CURSOR'
* 'RM06E-EPSTP(02)'.
* perform bdc_field using 'BDC_OKCODE'
* '=DETA'.
* perform bdc_field using 'RM06E-EBELP'
* '10'.
* perform bdc_dynpro using 'SAPMM06E' '0120'.
* perform bdc_field using 'BDC_CURSOR'
* 'EKPO-WERKS(02)'.
* perform bdc_field using 'BDC_OKCODE'
* '/00'.
* perform bdc_field using 'RM06E-EBELP'
* '10'.
*perform bdc_field using 'RM06E-EPSTP(02)'
* 'd'.
*perform bdc_field using 'EKPO-KNTTP(02)'
* 'n'.
*perform bdc_field using 'EKPO-TXZ01(02)'
* 'adage artwork'.
*perform bdc_field using 'EKPO-MENGE(02)'
* ' 1'.
*perform bdc_field using 'RM06E-EEIND(02)'
* '06242008'.
*perform bdc_field using 'EKPO-MATKL(02)'
* 'm1'.
*perform bdc_field using 'EKPO-WERKS(02)'
* 'a001'.
* perform bdc_field using 'BDC_OKCODE'
* '/00'.
perform bdc_dynpro using 'SAPMM06E' '0111'.
perform bdc_field using 'BDC_CURSOR'
'EKPO-MENGE'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
* perform bdc_field using 'EKPO-MATKL'
* 'M1'.
* perform bdc_field using 'EKPO-TXZ01'
* wa_jtab-j4.
* perform bdc_field using 'EKPO-PRSDR'
* 'X'.
* perform bdc_field using 'RM06E-EEIND'
* wa_jtab-j6.
perform bdc_field using 'RM06E-LPEIN'
'D'.
perform bdc_field using 'EKPO-WEPOS'
'X'.
perform bdc_field using 'EKPO-UEBTK'
'X'.
perform bdc_field using 'EKPO-WEBRE'
'X'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BDC_OKCODE'
'=ENTE'.
move 1 to idx.
perform bdc_dynpro using 'SAPLMLSP' '0200'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BDC_OKCODE'
'=ENTE'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RM11P-HEADTEXT'
'adage'.
perform bdc_field using 'BDC_CURSOR' 'ESLL-TBTWR(01)'.
perform bdc_field using 'RM11P-NEW_ROW'
'10'.
* concatenate 'ESLL-KTEXT1(0' idx ')' into fnaml.
* perform bdc_field using fnaml wa_ktab-k1.
* concatenate 'ESLL-MENGE(0' idx ')' into fnaml.
* perform bdc_field using fnaml wa_ktab-k2.
* concatenate 'ESLL-MEINS(0' idx ')' into fnaml.
* perform bdc_field using fnaml wa_ktab-k3.
* concatenate 'ESLL-TBTWR(0' idx ')' into fnaml.
* perform bdc_field using fnaml wa_ktab-k4.
* IDX = IDX + 1.
* loop at KT_STAGING where vendor = it_staging-vendor and docdate = it_staging-docdate and itmcategory is not initial.
IF TI_STAGING-ITMCATEGORY IS NOT INITIAL.
qty = ti_staging-serqty.
gp = ti_staging-sergrossprice.
perform bdc_field using 'ESLL-KTEXT1(01)' TI_STAGING-sertext.
perform bdc_field using 'ESLL-MENGE(01)' qty.
perform bdc_field using 'ESLL-MEINS(01)' TI_STAGING-seruom.
perform bdc_field using 'ESLL-TBTWR(01)' gp.
* endloop.
* move 1 to cnt.
* loop at KT_STAGING WHERE VENDOR = IT_STAGING-VENDOR AND DOCDATE = IT_STAGING-DOCDATE and itmcategory is not initial.
perform bdc_dynpro using 'SAPLMLSK' '0200'.
perform bdc_field using 'BDC_CURSOR'
'RM11K-VORNR(01)'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'VRTKZ1'
'X'.
* concatenate 'ESKN-SAKTO(0' IDX ')' into fnamk.
* perform bdc_field using fnam wa_ktab-k5.
* concatenate 'ESKN-NPLNR(0' IDX ')' into fnamk.
* perform bdc_field using fnam wa_ktab-k6.
* concatenate 'RM11K-VORNR(0' IDX ')' into fnamk.
* perform bdc_field using fnam wa_ktab-k7.
* cnt = cnt + 1.
PERFORM BDC_FIELD USING 'ESKN-SAKTO(01)' TI_STAGING-serglaccount.
PERFORM BDC_FIELD USING 'ESKN-NPLNR(01)' TI_STAGING-sernetwork.
PERFORM BDC_FIELD USING 'RM11K-VORNR(01)' TI_STAGING-seractivity.
* endloop.
perform bdc_dynpro using 'SAPLKACB' '0002'.
perform bdc_field using 'BDC_CURSOR'
'COBL-NPLNR'.
perform bdc_field using 'BDC_OKCODE'
'=ENTE'.
perform bdc_field using 'COBL-NPLNR'
kt_STAGING-sernetwork.
perform bdc_field using 'COBL-VORNR'
kt_STAGING-seractivity.
perform bdc_dynpro using 'SAPLMLSK' '0200'.
perform bdc_field using 'BDC_CURSOR'
'ESLL-INTROW'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'VRTKZ1'
'X'.
perform bdc_dynpro using 'SAPMM06E' '0200'.
perform bdc_field using 'BDC_CURSOR'
'RM06E-EBELP'.
perform bdc_field using 'BDC_OKCODE'
'=BACK'.
perform bdc_dynpro using 'SAPLMLSP' '0200'.
perform bdc_field using 'BDC_OKCODE'
'=SAV'.
ELSE.
perform bdc_dynpro using 'SAPMM06E' '0100'.
perform bdc_field using 'BDC_OKCODE'
'=SAV'.
ENDIF.
endloop.
*perform bdc_field using 'RM11P-HEADTEXT'
* 'adage artwork'.
* perform bdc_field using 'BDC_CURSOR'
* 'ESLL-KTEXT1(01)'.
*perform bdc_field using 'RM11P-NEW_ROW'
* '10'.
*perform bdc_transaction using 'ME21'.
CALL TRANSACTION 'ME21' USING I_BDCDATA MODE 'A' messages into i_msg.
*clear: kt_staging,ti_staging,it_staging,i_bdcdata.
endloop.
* CALL FUNCTION 'BDC_INSERT'
* EXPORTING
* TCODE = 'ME21'
** POST_LOCAL = NOVBLOCAL
** PRINTING = NOPRINT
** SIMUBATCH = ' '
** CTUPARAMS = ' '
* TABLES
* DYNPROTAB = I_BDCDATA
** EXCEPTIONS
** INTERNAL_ERROR = 1
** NOT_OPEN = 2
** QUEUE_ERROR = 3
** TCODE_INVALID = 4
** PRINTING_INVALID = 5
** POSTING_INVALID = 6
** OTHERS = 7
* IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
* ENDIF.
*Using Call Transaction Statement Call the transaction in back ground mode/fore ground mode
LOOP AT I_MSG.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = I_MSG-MSGID
LANG = SY-LANGU
NO = I_MSG-MSGNR
V1 = I_MSG-MSGV1
V2 = I_MSG-MSGV2
V3 = I_MSG-MSGV3
V4 = I_MSG-MSGV4
IMPORTING
MSG = W_STR
* EXCEPTIONS
* NOT_FOUND = 1
* OTHERS = 2
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
WRITE:/ i_msg-msgnr,w_str.
endloop.
* CALL FUNCTION 'BDC_CLOSE_GROUP'.
*** EXCEPTIONS
*** NOT_OPEN = 1
*** QUEUE_ERROR = 2
*** OTHERS = 3
** IF SY-SUBRC <> 0.
*** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*** WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
** ENDIF.
*perform close_group.
* Start new screen *
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR I_BDCDATA.
I_BDCDATA-PROGRAM = PROGRAM.
I_BDCDATA-DYNPRO = DYNPRO.
I_BDCDATA-DYNBEGIN = 'X'.
APPEND I_BDCDATA.
ENDFORM. "BDC_DYNPRO
* Insert field *
FORM BDC_FIELD USING FNAM FVAL.
* IF FVAL <> SPACE.
CLEAR I_BDCDATA.
I_BDCDATA-FNAM = FNAM.
I_BDCDATA-FVAL = FVAL.
APPEND I_BDCDATA.
* ENDIF.
ENDFORM. "BDC_FIELD -
Dear All,
I have a requirement to create PO using transaction ME21N. I had written a code to create PO using BDC for transaction ME21. But the user wants it to be modified to ME21N. The user wants the PO created in the foreground like the one i created fro ME21. But is it possible to use BDC for ME21N or is there any other way i can change the BAPI to foreground processing like in BDC?
Regards,
KarthikHi Raghavender,
This is a report to display and validate the RFQ's. And once the user selects the RFQ and clicks on Create PO from RFQ push button, it should go to transaction 'ME21N' with values from RFQ. ( similar to what we do in ME21N, when we drag RFQ from the documents overview and drop it into cart, the values are populated). I want the similar functionality to happen when the user clicks on clicks on Create PO push button. But it should happen only in the foreground and not background.
Regards,
Karthik -
BDC for ME21N (Flat file format)
Hello,
I have to write a BDC for ME21N(stock transfer).... Someone pls give me the format of flat file... we need separate files for header and items or only one file is enough??? pls someone send me the format and code......
my email id is [email protected]
Thanks in advance...
Regards,
Maya.Hi
see this and do accordingly
REPORT zmm_bdcp_purchaseorderkb02
NO STANDARD PAGE HEADING LINE-SIZE 255.
Declaring internal tables *
*-----Declaring line structure
DATA : BEGIN OF it_dummy OCCURS 0,
dummy(255) TYPE c,
END OF it_dummy.
*-----Internal table for line items
DATA : BEGIN OF it_idata OCCURS 0,
ematn(18), "Material Number.
menge(13), "Qyantity.
netpr(11), "Net Price.
werks(4), "Plant.
ebelp(5), "Item Number.
END OF it_idata.
*-----Deep structure for header data and line items
DATA : BEGIN OF it_me21 OCCURS 0,
lifnr(10), "Vendor A/c No.
bsart(4), "A/c Type.
bedat(8), "Date of creation of PO.
ekorg(4), "Purchasing Organisation.
ekgrp(3), "Purchasing Group.
x_data LIKE TABLE OF it_idata,
END OF it_me21.
DATA : x_idata LIKE LINE OF it_idata.
DATA : v_delimit VALUE ','.
DATA : v_indx(3) TYPE n.
DATA : v_fnam(30) TYPE c.
DATA : v_count TYPE n.
DATA : v_ne TYPE i.
DATA : v_ns TYPE i.
*include bdcrecx1.
INCLUDE zmm_incl_purchaseorderkb01.
Search help for file *
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
IMPORTING
file_name = p_file.
START-OF-SELECTION.
To upload the data into line structure *
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
filename = p_file
filetype = 'DAT'
TABLES
data_tab = it_dummy.
Processing the data from line structure to internal tables *
REFRESH:it_me21.
CLEAR :it_me21.
LOOP AT it_dummy.
IF it_dummy-dummy+0(01) = 'H'.
v_indx = v_indx + 1.
CLEAR it_idata.
REFRESH it_idata.
CLEAR it_me21-x_data.
REFRESH it_me21-x_data.
SHIFT it_dummy.
SPLIT it_dummy AT v_delimit INTO it_me21-lifnr
it_me21-bsart
it_me21-bedat
it_me21-ekorg
it_me21-ekgrp.
APPEND it_me21.
ELSEIF it_dummy-dummy+0(01) = 'L'.
SHIFT it_dummy.
SPLIT it_dummy AT v_delimit INTO it_idata-ematn
it_idata-menge
it_idata-netpr
it_idata-werks
it_idata-ebelp.
APPEND it_idata TO it_me21-x_data.
MODIFY it_me21 INDEX v_indx.
ENDIF.
ENDLOOP.
To open the group *
PERFORM open_group.
To populate the bdcdata table for header data *
LOOP AT it_me21.
v_count = v_count + 1.
REFRESH it_bdcdata.
PERFORM subr_bdc_table USING: 'X' 'SAPMM06E' '0100',
' ' 'BDC_CURSOR' 'EKKO-LIFNR',
' ' 'BDC_OKCODE' '/00',
' ' 'EKKO-LIFNR' it_me21-lifnr,
' ' 'RM06E-BSART' it_me21-bsart,
' ' 'RM06E-BEDAT' it_me21-bedat,
' ' 'EKKO-EKORG' it_me21-ekorg,
' ' 'EKKO-EKGRP' it_me21-ekgrp,
' ' 'RM06E-LPEIN' 'T'.
PERFORM subr_bdc_table USING: 'X' 'SAPMM06E' '0120',
' ' 'BDC_CURSOR' 'RM06E-EBELP',
' ' 'BDC_OKCODE' '/00'.
MOVE 1 TO v_indx.
*-----To populate the bdcdata table for line item data
LOOP AT it_me21-x_data INTO x_idata.
CONCATENATE 'EKPO-EMATN(' v_indx ')' INTO v_fnam.
PERFORM subr_bdc_table USING ' ' v_fnam x_idata-ematn.
CONCATENATE 'EKPO-MENGE(' v_indx ')' INTO v_fnam.
PERFORM subr_bdc_table USING ' ' v_fnam x_idata-menge.
CONCATENATE 'EKPO-NETPR(' v_indx ')' INTO v_fnam.
PERFORM subr_bdc_table USING ' ' v_fnam x_idata-netpr.
CONCATENATE 'EKPO-WERKS(' v_indx ')' INTO v_fnam.
PERFORM subr_bdc_table USING ' ' v_fnam x_idata-werks.
v_indx = v_indx + 1.
PERFORM subr_bdc_table USING: 'X' 'SAPMM06E' '0120',
' ' 'BDC_CURSOR' 'RM06E-EBELP',
' ' 'BDC_OKCODE' '/00'.
ENDLOOP.
PERFORM subr_bdc_table USING: 'X' 'SAPMM06E' '0120',
' ' 'BDC_CURSOR' 'RM06E-EBELP',
' ' 'BDC_OKCODE' '=BU'.
PERFORM bdc_transaction USING 'ME21'.
ENDLOOP.
PERFORM close_group.
End of selection event *
END-OF-SELECTION.
IF session NE 'X'.
*-----To display the successful records
WRITE :/10 text-001. "Sucess records
WRITE :/10 SY-ULINE(20).
SKIP.
IF it_sucess IS INITIAL.
WRITE :/ text-002.
ELSE.
WRITE :/ text-008, "Total number of Succesful records
35 v_ns.
SKIP.
WRITE:/ text-003, "Vendor Number
17 text-004, "Record number
30 text-005. "Message
ENDIF.
LOOP AT it_sucess.
WRITE:/4 it_sucess-lifnr,
17 it_sucess-tabix CENTERED,
30 it_sucess-sucess_rec.
ENDLOOP.
SKIP.
*-----To display the erroneous records
WRITE:/10 text-006. "Error Records
WRITE:/10 SY-ULINE(17).
SKIP.
IF it_error IS INITIAL.
WRITE:/ text-007. "No error records
ELSE.
WRITE:/ text-009, "Total number of erroneous records
35 v_ne.
SKIP.
WRITE:/ text-003, "Vendor Number
17 text-004, "Record number
30 text-005. "Message
ENDIF.
LOOP AT it_error.
WRITE:/4 it_error-lifnr,
17 it_error-tabix CENTERED,
30 it_error-error_rec.
ENDLOOP.
REFRESH it_sucess.
REFRESH it_error.
ENDIF.
CODE IN INCLUDE.
Include ZMM_INCL_PURCHASEORDERKB01
DATA: it_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
DATA: it_MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
DATA: E_GROUP_OPENED.
*-----Internal table to store sucess records
DATA:BEGIN OF it_sucess OCCURS 0,
msgtyp(1) TYPE c,
lifnr LIKE ekko-lifnr,
tabix LIKE sy-tabix,
sucess_rec(125),
END OF it_sucess.
DATA: g_mess(125) type c.
*-----Internal table to store error records
DATA:BEGIN OF it_error OCCURS 0,
msgtyp(1) TYPE c,
lifnr LIKE ekko-lifnr,
tabix LIKE sy-tabix,
error_rec(125),
END OF it_error.
Selection screen
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS session RADIOBUTTON GROUP ctu. "create session
SELECTION-SCREEN COMMENT 3(20) text-s07 FOR FIELD session.
SELECTION-SCREEN POSITION 45.
PARAMETERS ctu RADIOBUTTON GROUP ctu. "call transaction
SELECTION-SCREEN COMMENT 48(20) text-s08 FOR FIELD ctu.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 3(20) text-s01 FOR FIELD group.
SELECTION-SCREEN POSITION 25.
PARAMETERS group(12). "group name of session
SELECTION-SCREEN COMMENT 48(20) text-s05 FOR FIELD ctumode.
SELECTION-SCREEN POSITION 70.
PARAMETERS ctumode LIKE ctu_params-dismode DEFAULT 'N'.
"A: show all dynpros
"E: show dynpro on error only
"N: do not display dynpro
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 48(20) text-s06 FOR FIELD cupdate.
SELECTION-SCREEN POSITION 70.
PARAMETERS cupdate LIKE ctu_params-updmode DEFAULT 'L'.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 3(20) text-s03 FOR FIELD keep.
SELECTION-SCREEN POSITION 25.
PARAMETERS: keep AS CHECKBOX. "' ' = delete session if finished
"'X' = keep session if finished
SELECTION-SCREEN COMMENT 48(20) text-s09 FOR FIELD e_group.
SELECTION-SCREEN POSITION 70.
PARAMETERS e_group(12). "group name of error-session
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 51(17) text-s03 FOR FIELD e_keep.
SELECTION-SCREEN POSITION 70.
PARAMETERS: e_keep AS CHECKBOX. "' ' = delete session if finished
"'X' = keep session if finished
SELECTION-SCREEN END OF LINE.
PARAMETERS:p_file LIKE rlgrap-filename.
at selection screen *
AT SELECTION-SCREEN.
group and user must be filled for create session
IF SESSION = 'X' AND
GROUP = SPACE. "OR USER = SPACE.
MESSAGE E613(MS).
ENDIF.
create batchinput session *
FORM OPEN_GROUP.
IF SESSION = 'X'.
SKIP.
WRITE: /(20) 'Create group'(I01), GROUP.
SKIP.
*----open batchinput group
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = GROUP
USER = sy-uname.
WRITE:/(30) 'BDC_OPEN_GROUP'(I02),
(12) 'returncode:'(I05),
SY-SUBRC.
ENDIF.
ENDFORM. "OPEN_GROUP
end batchinput session *
FORM CLOSE_GROUP.
IF SESSION = 'X'.
*------close batchinput group
CALL FUNCTION 'BDC_CLOSE_GROUP'.
WRITE: /(30) 'BDC_CLOSE_GROUP'(I04),
(12) 'returncode:'(I05),
SY-SUBRC.
ELSE.
IF E_GROUP_OPENED = 'X'.
CALL FUNCTION 'BDC_CLOSE_GROUP'.
WRITE: /.
WRITE: /(30) 'Fehlermappe wurde erzeugt'(I06).
ENDIF.
ENDIF.
ENDFORM. "CLOSE_GROUP
Start new transaction according to parameters *
FORM BDC_TRANSACTION USING TCODE TYPE ANY.
DATA: L_SUBRC LIKE SY-SUBRC.
*------batch input session
IF SESSION = 'X'.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = TCODE
TABLES
DYNPROTAB = it_BDCDATA.
WRITE: / 'BDC_INSERT'(I03),
TCODE,
'returncode:'(I05),
SY-SUBRC,
'RECORD:',
SY-INDEX.
ELSE.
REFRESH it_MESSTAB.
CALL TRANSACTION TCODE USING it_BDCDATA
MODE CTUMODE
UPDATE CUPDATE
MESSAGES INTO it_MESSTAB.
L_SUBRC = SY-SUBRC.
WRITE: / 'CALL_TRANSACTION',
TCODE,
'returncode:'(I05),
L_SUBRC,
'RECORD:',
SY-INDEX.
ENDIF.
Message handling for Call Transaction *
perform subr_mess_hand using g_mess.
*-----Erzeugen fehlermappe
IF L_SUBRC <> 0 AND E_GROUP <> SPACE.
IF E_GROUP_OPENED = ' '.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = E_GROUP
USER = sy-uname
KEEP = E_KEEP.
E_GROUP_OPENED = 'X'.
ENDIF.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = TCODE
TABLES
DYNPROTAB = it_BDCDATA.
ENDIF.
REFRESH it_BDCDATA.
ENDFORM. "BDC_TRANSACTION
Form subr_bdc_table *
text
-->P_0220 text *
-->P_0221 text *
-->P_0222 text *
FORM subr_bdc_table USING VALUE(P_0220) TYPE ANY
VALUE(P_0221) TYPE ANY
VALUE(P_0222) TYPE ANY.
CLEAR it_bdcdata.
IF P_0220 = ' '.
CLEAR it_bdcdata.
it_bdcdata-fnam = P_0221.
it_bdcdata-fval = P_0222.
APPEND it_bdcdata.
ELSE.
it_bdcdata-dynbegin = P_0220.
it_bdcdata-program = P_0221.
it_bdcdata-dynpro = P_0222.
APPEND it_bdcdata.
ENDIF.
ENDFORM. " subr_bdc_table
Form subr_mess_hand *
text *
-->P_G_MESS text *
FORM subr_mess_hand USING P_G_MESS TYPE ANY.
LOOP AT IT_MESSTAB.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = it_messtab-msgid
LANG = it_messtab-msgspra
NO = it_messtab-msgnr
v1 = it_messtab-msgv1
v2 = it_messtab-msgv2
IMPORTING
MSG = P_G_MESS
EXCEPTIONS
OTHERS = 0.
CASE it_messtab-msgtyp.
when 'E'.
it_error-error_rec = P_G_MESS.
it_error-lifnr = it_me21-lifnr.
it_error-tabix = v_count.
APPEND IT_ERROR.
when 'S'.
it_sucess-sucess_rec = P_G_MESS.
it_sucess-lifnr = it_me21-lifnr.
it_sucess-tabix = v_count.
APPEND IT_SUCESS.
endcase.
ENDLOOP.
Describe table it_sucess lines v_ns.
Describe table it_error lines v_ne.
ENDFORM. " subr_mess_hand
Regards
Anji -
Hi is it possible to write bdc for me21n
i m try it but it int trnasfer data
Moderator Message: Vague question.
Edited by: kishan P on Dec 13, 2010 8:30 PMHi Sandeep,
Please use standard Bapi for creating purchase order using the Enjoy Transaction. BAPI_PO_CREATE1.
Your previous thread, title "bapi to create PO", will give you the details.
Regards
Bhanu -
Doubt in uploading purchase order data using BDC
Hi friends,
how to upload purchase order data.
1) In both BDC and BAPI which one is preferable?
2) for suppose if it is through BDC, how to use? what are the transactions that we can use(SHDB, ME21N,ME21)?
3) To execute the job in background, is it possible for both call transaction and session method.
Thanks in advance
Sreenivas kIt really depends on the number of records you have. Still for a set of 5,000 records my answer to your questions will be:
1) In both BDC and BAPI which one is preferable? - <b>Go with BDC</b>
2) for suppose if it is through BDC, how to use? what are the transactions that we can use(SHDB, ME21N,ME21)? - <b>Yes, its SHDB for recording, SE38 for abap program and ME21 for PO. Avoid SAP Enjoy transactions for recording as you may end up having problems wiht it.</b>
3) To execute the job in background, is it possible for both call transaction and session method. - <b>If you use call transaction method then you have to schedule the job to run in background or simply run it through F9 instead of F8. In case of session method you can chose to process the session in background. However I would suggest you go with BDC Session method for this.</b>
- Guru
Reward points for helpful answers -
How to transfer data in A tableview control in transaction ME21n
Dear friends,
I m new in the field of SAP ABAP.
And right now i m trying to transfer the data in a tableview control in transaction ME21n. I've recorded the sequence of mandatory fields in transaction ME21n but, when i try to transfer the data using BDC call transaction method the order of manadatory fields change.
I m trying to transfer data from text file.
If anybody has a solution to this problem please tell me how to sort out this.
Thanks in advance.Hi Vivek,
Welcome to SDN.
BDC solution will not work with transaction ME21N.
ME21N is an enjoy SAP transaction which has a lot of new objects that BDC can not call/use.
Please use transaction ME21 instead of ME21N.
Hope this will help.
Regards,
Ferry Lianto
Please reward points in helpful. -
MIGO BDC is not working in Scheduled BG Job
Hello,
For Subcontracting Purchase Order Item, we are using the BDC Call Transaction method for the TCode
MIGO in the program 'ZMIGO_TEST'.
When we are testing the Program 'ZMIGO_TEST' through SE38 it is running successfuly and document is also posted but problem is when we schedule the same program 'ZMIGO_TEST' in SM36, same BDC code for MIGO Transaction is not working and giving the Error in IST_BDCMSGCOLL as folloow.
MSGID: - DC
MSGTYP: - S
MSGNR: - 006
DYNAME: - 0001
MSGV4: - SAPLMIGO
NOTE: - We can not use the BAPI 'BAPI_GOODSMVT_CREATE' because we have to update the Challan Number and Challan Year also for each PO Line Item and this BAPI does not have thses two fields in its Parameter Interface.
Please suggest.
Thanks & Regards
Jageshhi,
check below tcodes..
Subcontracting Process
Subcontracting without Payment of Duty
Creation of Subcontracting PO (ME21N)
Transfer Posting of Components to Subcontractor (Mvmt Type - 541) (MB1B/ME2O/MIGO)
Creation of Subcontracting Challan w.r.t. Transfer Posting Doc (J1IF01)
Goods Receipt w.r.t. Subcontracting PO and Refer Subcontracting Challan at the time of GR (MIGO) {GR with 101 and auto consumption of components with 543 movement}
Reconciliation of Subcontracting Challan (J1IFQ)
Completion of Subcontracting Challan (J1IF13)
Generation of Annexure IV (J1IFR)
Note: - In this case, you have to maintain the Assessable Value for the Components to be supplied to Vendor in J1ID and also Excise Tax rates for the Chapter IDs linked with these components. So during J1IF01, system will take the Assessable Value as Excise base Value and calculates the Excise Duties by taking Excise Tax Rates.
Subcontracting under Full Payment of Duty
Creation of Subcontracting PO (ME21N)
Transfer Posting of Components to Subcontractor (MB1B/ME2O/MIGO)
Creation of Outgoing Excise Invoice w.r.t. Transfer Posting Document (J1IS) - Used to send the components to Subcontractor's. Here 57F4 Challan is not created.
Accounting Entry: -
CENVAT Input BED - Cr
CENVAT Input ECS - Cr
CENVAT Input ECS - Cr
CENVAT Suspense A/c - Dr
Capture Vendor Excise Invoice at the time of GR of Finished Goods w.r.t. Subcontracting PO (MIGO)
Post Excise Invoice for FG received from Subcontractor (J1IEX)
Accounting Entry: -
CENVAT Input BED - Dr
CENVAT Input ECS - Dr
CENVAT Input ECS - Dr
CENVAT Clearing A/c - Cr
Master Data:-
MM01- Material Masters for Components and FG
XK01 - Vendor Master (Subcontractor)
CS01 - BOM for FG
ME11 - Purchase Info record for Subcontracting -
Out of stock Sales Order Item to trigger a BDC to create a PO
Dear ABAPers,
I have a couple of questions:
1. In the sales order program code, how do you find out if an item being ordered is out of stock? Which tables and fields do you check?
2. when an item is determined to be out of stock, we want to trigger a BDC to create a PO. How do you do that?
I know these are big questions. You can give me either an overview or detail solution, it's up to you.
Thanks!Hi,
Assuming all the basic settings are configured
Step1: Run T Code VA01 and input the u201Cdocument typeu201D as OR along with your sales area. Then enter your business partner number along with the material number and quantity. Save the order.
Step2: T Code VA03 input the order number which you have created. Select the line item and (menu bar) Goto u2013 Items u2013 Schedule lines. You will find the u201Cpurchase requisitionu201D for that item just copy the number.
Note: If you unable to see the u201Cpurchase requ201D in the sales order then make sure you need to change the Item category group of a material in MM02 as BANC in Sales: sales org 2 tab.
Step3: Run T Code ME21N under the item paste the u201Cpurchase requisitionu201D number generated at sales order level and hit enter that will automatically give all the details, save. You can save the Purchase order.
This scenario will only help to create purchase order until I know why you want to create a purchase order I canu2019t proceed further. -
BDC to create purchase requistion
Hi ,
Can purchase req. be created using BSC?
if yes then how, what are the mandatory fields for BDC recording for purchase requisition?
Thanks
LovleenYou can not create BDC for purchase order creation by T-Code ME21n as it is using ALV for items. But you can use thold transaction ME21 to create purchase order by BDC. But better to use BAPI or functional module.
Maybe you are looking for
-
Error message in processing log in VA02 in External send.
Hi, In my smartform I am using READ_TEXT to read one text and I have checked the exceptions also in the call to function module. CALL FUNCTION 'READ_TEXT' EXPORTING ID = 'ST' LANGUAGE = ZNAST-SPRAS NAME
-
Spellchecking doesn't work in hotmail
I've recently changed my browser to firefox from internet explorer and now the spellchecker doesn't work in hotmail. It says the browser is checking the spelling automatically but it's not. I found a forum thread that told me to right click make sure
-
Download java output to word doc
Hi , I would like to download the java output iview into Word document. IS it possible ? Thanks and regards, Sithi
-
I'm trying to make links to show and then play a few slideshows. I have multiple layers in DW that show or hide depending on which selection is made on the menu bar. The problem is that I wanted the text on each "page" (layer) to slide in horizontall
-
I cant purchase the money to my account
cant purchase the money to app games(wechat games <Email Edited by Host>