02-19-2009 4:37 AM
i am facing problem while doing BDC for ME22N . i am going for itemwise vendor confirmation.
for first line item it is happening. but for 2nd line item it is not going.
any help?
this is my code. i guess some loop i have to add but where? can any body give idea?
REPORT ZMM_VC_UPLOAD.
TABLES : t100.
************************************************************************
Internal table declaration *
************************************************************************
DATA : BEGIN OF it_upload OCCURS 0,
index(4), "Index
EBELN(10), "PO number
EBELP(5), "line item PO
LIST(1), "item number
BSTAE(4), "Confirmation control key
EBTYP(2), "Confirmation Category
BSTAE(4), "Confirmation control key
LPEIN(1), "Category of delivery date
EEIND(10), "delivery date
MENGE(13), "QTY Quantity as per vendor confirmation
XBLNR(20), "ext doc
ERDAT(10), "doc date
er_message(100),
END OF it_upload.
DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE,
MSGDATA LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
********************************************************************
*Selection Screen
********************************************************************
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETER: P_FILE LIKE IBIPPARMS-PATH OBLIGATORY. "to select a file.
SELECTION-SCREEN END OF BLOCK B1.
********************************************************************
*Initialization
********************************************************************
INITIALIZATION.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE .
PERFORM GET_FILENAME.
********************************************************************
start-of-selection
********************************************************************
START-OF-SELECTION.
PERFORM MAKE_FILE_NAME .
PERFORM UPLOAD_FILE.
PERFORM BDC_PROCESS.
perform read_messages.
&----
*& Form UPLOAD_FILE
&----
FORM UPLOAD_FILE .
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = P_FILE
FILETYPE = 'DAT'
TABLES
DATA_TAB = IT_UPLOAD .
IF SY-SUBRC <> 0.
ENDIF.
ENDFORM. " UPLOAD_FILE
&----
*& Form bdc_process
&----
FORM BDC_PROCESS .
loop at it_upload.
LOOP AT IT_header.
refresh bdcdata.
perform bdc_dynpro using 'SAPLMEGUI' '0014'.
perform bdc_field using 'BDC_OKCODE'
'=MECHOB'.
perform bdc_field using 'MEPO_TOPLINE-BSART'
'NB'.
perform bdc_field using 'DYN_6000-LIST'
it_upload-list. "' 1'.
perform bdc_field using 'BDC_CURSOR'
'MEPO1319-MATKL'.
perform bdc_field using 'MEPO1319-SPINF'
'X'.
perform bdc_dynpro using 'SAPLMEGUI' '0002'.
perform bdc_field using 'BDC_OKCODE'
'=MEOK'.
perform bdc_field using 'BDC_CURSOR'
'MEPO_SELECT-EBELN'.
perform bdc_field using 'MEPO_SELECT-EBELN'
it_upload-EBELN. "'4500195517'.
perform bdc_field using 'MEPO_SELECT-BSTYP_F'
'X'.
perform bdc_dynpro using 'SAPLMEGUI' '0014'.
perform bdc_field using 'BDC_OKCODE'
'=TABIDT14'.
perform bdc_field using 'BDC_CURSOR'
'MEPO_TOPLINE-BSART'.
perform bdc_field using 'MEPO_TOPLINE-BSART'
'NB'.
perform bdc_field using 'DYN_6000-LIST'
it_upload-list. "' 1'.
perform bdc_field using 'MEPO1319-SPINF'
'X'.
perform bdc_dynpro using 'SAPLMEGUI' '0014'.
perform bdc_field using 'BDC_OKCODE' "first time
'/00'.
perform bdc_field using 'MEPO_TOPLINE-BSART'
'NB'.
perform bdc_field using 'DYN_6000-LIST'
it_upload-list. " ' 1'.
perform bdc_field using 'BDC_CURSOR'
'MEPO1334-BSTAE'.
perform bdc_field using 'MEPO1334-BSTAE'
it_upload-BSTAE . "'0005'.
perform bdc_dynpro using 'SAPLMEGUI' '0014'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MEPO_TOPLINE-BSART'
'NB'.
*loop at it_item where ebeln = it_upload-ebeln.
perform bdc_field using 'BDC_CURSOR'
'DYN_6000-LIST'.
perform bdc_field using 'DYN_6000-LIST'
it_upload-list. "' 1'.
perform bdc_field using 'MEPO1334-BSTAE'
it_upload-BSTAE. "'0005'.
perform bdc_field using 'BDC_CURSOR'
'EKES-ERDAT(01)'.
perform bdc_field using 'EKES-EBTYP(01)'
it_upload-EBTYP. "'vc'.
perform bdc_field using 'RM06E-LPEIN(01)'
it_upload-LPEIN. "'D'.
perform bdc_field using 'RM06E-EEIND(01)'
it_upload-EEIND. "'15.02.2009'.
perform bdc_field using 'EKES-MENGE(01)'
it_upload-MENGE. "'10'.
perform bdc_field using 'EKES-XBLNR(01)'
it_upload-XBLNR. "'inv 9'.
perform bdc_field using 'EKES-ERDAT(01)'
it_upload-ERDAT. "'15.02.2009'.
perform bdc_dynpro using 'SAPLMEGUI' '0014'.
perform bdc_field using 'BDC_OKCODE'
'=MESAVE'.
CALL TRANSACTION 'ME22N' USING BDCDATA MODE 'A' UPDATE 'A' MESSAGES INTO MSGDATA.
CLEAR: BDCDATA,BDCDATA[].
refresh BDCDATA.
ENDLOOP.
ENDFORM. " bdc_process
----
Start new screen *
----
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
ENDFORM. "BDC_DYNPRO
----
Insert field *
----
FORM BDC_FIELD USING FNAM FVAL.
IF FVAL <> ''.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
ENDIF.
ENDFORM. "BDC_FIELD
----
*To get file name *
----
FORM GET_FILENAME .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
IMPORTING
FILE_NAME = P_FILE.
IF SY-SUBRC NE 0 .
WRITE : / 'Enter File Name'.
ENDIF.
ENDFORM. "GET_FILENAME
02-19-2009 4:53 AM
Hi dude,
Go through this link:[https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/alvForPurchaseOrderPrintingandBDConME22NforChangingheadertext]
02-19-2009 5:55 AM
02-19-2009 10:51 AM
Hello,
ME22N is an enjoy transaction and hence you can't use BDC as they are bound to fail in background run due to presence of activex controls on the screen.
Instead Use can use ME22 for developing a BDC or else use a BAPI for changing the document.
Thanks,
Kartavya Kaushik.
02-19-2009 5:16 PM
Hi Dude,
When ur looping the item information , in your code ur
loop at it_item where ebeln = it_upload-ebeln.
perform bdc_field using 'BDC_CURSOR'
'DYN_6000-LIST'.
perform bdc_field using 'DYN_6000-LIST'
it_upload-list. "' 1'.
perform bdc_field using 'MEPO1334-BSTAE'
it_upload-BSTAE. "'0005'.
perform bdc_field using 'BDC_CURSOR'
'EKES-ERDAT(01)'.
perform bdc_field using 'EKES-EBTYP(01)'
it_upload-EBTYP. "'vc'.
perform bdc_field using 'RM06E-LPEIN(01)'
it_upload-LPEIN. "'D'.
perform bdc_field using 'RM06E-EEIND(01)'
it_upload-EEIND. "'15.02.2009'.
perform bdc_field using 'EKES-MENGE(01)'
it_upload-MENGE. "'10'.
perform bdc_field using 'EKES-XBLNR(01)'
it_upload-XBLNR. "'inv 9'.
perform bdc_field using 'EKES-ERDAT(01)'
it_upload-ERDAT. "'15.02.2009'.
perform bdc_dynpro using 'SAPLMEGUI' '0014'.
perform bdc_field using 'BDC_OKCODE'
'=MESAVE'.
-
->(01) you have to replace to variable , and every loop pass increment the varialbe value with 1.
ex : -
V1 = 1.
loop at item.
perform bdc_data using 'xyz(V1)'
it_upload-variable.
V1 = V1 + 1.
endloop.
This is called as index , the table control fields are differ the field name by index only...