11-27-2007 7:06 AM
Dear friends,
Can anyone please send me a sample code for uploading data using MIGO.
Udseful points to be rewarded.
Regards,
Gopi
11-27-2007 7:10 AM
Hi,
refer this code
&----
*& Report ZPRASH_BDC_MIGO
*&
&----
*&Developer
*&Transport
&----
REPORT zprash_bdc_migo.
----
TYPES *
----
TYPES : BEGIN OF t_migo,
po_number(10) TYPE c, "Purchase Order Number
doc_date(10) TYPE c, "Document Date
post_date(10) TYPE c, "Posting Date
del_note(16) TYPE c, "Delivery Note
bill_lad(16) TYPE c, "Bill of Lading
head_txt(25) TYPE c, "Header Text
qty(13) TYPE c, "Quantity
qty_note(13) TYPE c, "Quantity Note
lgort(4) TYPE c, "Storage Location
message(100) TYPE c,
END OF t_migo,
BEGIN OF t_ekpo,
ebeln TYPE ebeln, "Purchasing Document Number
ebelp TYPE ebelp, "Item Number of Purchasing Document
loekz TYPE loekz, "Deletion Indicator in Purchasing Document
matnr TYPE matnr, "Material Number
bukrs TYPE bukrs, "Company Code
elikz TYPE elikz, "Delivery Completed Indicator
END OF t_ekpo,
BEGIN OF t_marv,
bukrs TYPE bukrs, "Company Code
lfgja TYPE lfgja, "Fiscal Year of Current Period
lfmon TYPE lfmon, "Current period (posting period)
vmgja TYPE vmgja, "Fiscal year of previous period
vmmon TYPE vmmon, "Month of previous period
END OF t_marv,
BEGIN OF t_mard,
matnr TYPE matnr, "Material Number
werks TYPE werks_d, "Plant
lgort TYPE lgort_d, "Storage Location
END OF t_mard.
----
VARIABLES *
----
DATA: v_flag(1) TYPE c, "Variable for flag
v_last_flag(1) TYPE c, "Variable for flag
v_cnt(3) TYPE c. "Variable for flag
----
INTERNAL TABLES *
----
DATA : it_migo TYPE STANDARD TABLE OF t_migo,
it_error TYPE STANDARD TABLE OF t_migo,
it_ekpo TYPE STANDARD TABLE OF t_ekpo,
it_marv TYPE STANDARD TABLE OF t_marv,
it_mard TYPE STANDARD TABLE OF t_mard.
DATA BEGIN OF it_bdc_data OCCURS 100.
INCLUDE STRUCTURE bdcdata.
DATA END OF it_bdc_data.
----
WORK AREAS *
----
DATA : wa_migo TYPE t_migo, "Work Area for MIGO
wa_error TYPE t_migo, "Work Area for ERROR
wa_ekpo TYPE t_ekpo, "Work Area for EKPO
wa_marv TYPE t_marv, "Work Area for MARV
wa_mard TYPE t_mard. "Work Area for MARD
----
SELECTION SCREEN *
----
SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS : p_file LIKE rlgrap-filename OBLIGATORY,
p_chk AS CHECKBOX,
p_error LIKE rlgrap-filename,
p_sesn LIKE bgr00-group DEFAULT 'ZMIGO'.
SELECTION-SCREEN : SKIP 1.
PARAMETERS : p_rad1 RADIOBUTTON GROUP grp DEFAULT 'X',
p_rad2 RADIOBUTTON GROUP grp.
SELECTION-SCREEN : END OF BLOCK b1.
----
AT SELECTION-SCREEN ON VALUE-REQUEST *
----
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
*--This perform displays the f4 help for presentation server file name
user can select the file from presentation server
PERFORM sub_getfile.
----
AT SELECTION-SCREEN ON VALUE-REQUEST *
----
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_error.
*--This perform displays the f4 help for presentation server file name
user can select the file from presentation server
PERFORM sub_error_file.
----
AT SELECTION-SCREEN *
----
AT SELECTION-SCREEN.
*--This perform validates the selection screen
PERFORM sub_validate_screen.
----
START-OF-SELECTION
----
START-OF-SELECTION.
*--This perform selects the input file from presentation server
using Function GUI_UPLOAD and checks if their any error in input
file.
PERFORM sub_upload_file.
*--This perform validate the data from database tables
PERFORM sub_validate_data.
*--This perform download the error messages along with records
on presentation server and checks if error written successfully
or not.
PERFORM sub_download_data.
IF p_rad1 EQ 'X'.
IF NOT it_migo[] IS INITIAL.
*--This form opens the session using BDC_OPEN_GROUP and calls another
form bdc_session
PERFORM sub_transfer_data.
*--This perform insert the data into bdc table using function BDC_INSERT
and checks if session is created successfully or not
PERFORM sub_bdc_session.
*--This perform closes the session using funtion BDC_CLOSE_GROUP.
PERFORM sub_close_group.
ENDIF.
ELSEIF p_rad2 EQ 'X'.
IF NOT it_migo[] IS INITIAL.
*--This perform insert the data into bdc table using call transaction
PERFORM sub_call_transaction.
ENDIF.
ENDIF.
*ENDIF.
&----
*& Form sub_getfile
&----
text
----
FORM sub_getfile .
*--Call function module for f4 help
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = sy-cprog
dynpro_number = sy-dynnr
IMPORTING
file_name = p_file.
ENDFORM. " sub_getfile
&----
*& Form sub_error_file
&----
text
----
FORM sub_error_file .
*--Call function module for f4 help
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = sy-cprog
dynpro_number = sy-dynnr
IMPORTING
file_name = p_error.
ENDFORM. " sub_error_file
&----
*& Form sub_validate_screen
&----
text
----
FORM sub_validate_screen .
IF ( p_chk EQ 'X' ) AND
( p_error EQ space ).
MESSAGE 'Enter Error Filename' TYPE 'E'.
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM. " sub_validate_screen
&----
*& Form sub_upload_file
&----
text
----
FORM sub_upload_file .
*--Local Variables
DATA : lv_file TYPE string,
lv_index LIKE sy-tabix,
lv_date1 LIKE rc65a-datefrom,
lv_date2 LIKE sy-datum,
lv_date3 LIKE rc65a-datefrom,
lv_date4 LIKE sy-datum.
lv_file = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = lv_file
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = it_migo
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17
.
IF sy-subrc <> 0.
MESSAGE 'File not found' TYPE 'I'.
LEAVE LIST-PROCESSING.
ELSE.
LOOP AT it_migo INTO wa_migo.
lv_index = sy-tabix.
*--Call function to convert the date format
CALL FUNCTION 'CY_CONVERT_DATE'
EXPORTING
date_string_imp = wa_migo-doc_date
IMPORTING
date_string_exp = lv_date1
date_exp = lv_date2.
*--Call function to convert the date format
CALL FUNCTION 'CY_CONVERT_DATE'
EXPORTING
date_string_imp = wa_migo-post_date
IMPORTING
date_string_exp = lv_date3
date_exp = lv_date4.
wa_migo-doc_date = lv_date1.
wa_migo-post_date = lv_date3.
MODIFY it_migo FROM wa_migo INDEX lv_index TRANSPORTING
doc_date post_date.
*--Clear
CLEAR : wa_migo,
lv_date1,
lv_date2,
lv_date3,
lv_date4.
ENDLOOP.
ENDIF.
ENDFORM. " sub_upload_file
&----
*& Form sub_validate_data
&----
text
----
FORM sub_validate_data .
*--Local Variables
DATA : lv_index LIKE sy-tabix.
*--Sort Table bny purchase order number
SORT it_migo BY po_number.
IF NOT it_migo[] IS INITIAL.
*--Select query to pick the Purchasing Document Number Item
Number of Purchasing Document Deletion Indicator in
Purchasing Document Material Number Company Code Delivery
Completed Indicator from table EKPO
SELECT ebeln "Purchasing Document Number
ebelp "Item Number of Purchasing Document
loekz "Deletion Indicator in Purchasing Document
matnr "Material Number
bukrs "Company Code
elikz "Delivery Completed Indicator
FROM ekpo
INTO TABLE it_ekpo
FOR ALL ENTRIES IN it_migo
WHERE ebeln EQ it_migo-po_number.
IF sy-subrc EQ 0.
*--Sort table by purchasing document number
SORT it_ekpo BY ebeln.
*--Select query to pick the Company Code Fiscal Year of Current Period
Current period (posting period) Fiscal year of previous period
and Month of previous period from table MARV
SELECT bukrs "Company Code
lfgja "Fiscal Year of Current Period
lfmon "Current period (posting period)
vmgja "Fiscal year of previous period
vmmon "Month of previous period
FROM marv
INTO TABLE it_marv
FOR ALL ENTRIES IN it_ekpo
WHERE bukrs EQ it_ekpo-bukrs.
*--Select query to pick the material number plant and storage
location from table MARD
SELECT matnr "Material Number
werks "Plant
lgort "Storage Location
FROM mard
INTO TABLE it_mard
FOR ALL ENTRIES IN it_ekpo
WHERE matnr EQ it_ekpo-matnr.
ENDIF.
ENDIF.
IF NOT it_migo[] IS INITIAL.
*--Clear
CLEAR : wa_migo.
LOOP AT it_migo INTO wa_migo.
lv_index = sy-tabix.
*--Clear
CLEAR : wa_ekpo.
READ TABLE it_ekpo INTO wa_ekpo WITH KEY ebeln = wa_migo-po_number
BINARY SEARCH.
IF sy-subrc EQ 0.
IF wa_ekpo-loekz NE 'X'.
IF wa_ekpo-elikz NE 'X'.
*--Clear
CLEAR : wa_marv.
READ TABLE it_marv INTO wa_marv WITH KEY bukrs = wa_ekpo-bukrs.
IF sy-subrc EQ 0.
IF ( wa_migo-doc_date(2) LT wa_marv-vmmon ) OR
( wa_migo-doc_date(2) GE wa_marv-lfmon ).
MOVE-CORRESPONDING wa_migo TO wa_error.
wa_error-message = 'Incorrect posting date'.
DELETE it_migo INDEX lv_index.
ELSE.
MOVE-CORRESPONDING wa_migo TO wa_error.
wa_error-message = 'Record Uploaded Successfully'.
ENDIF.
ENDIF.
ELSE.
MOVE-CORRESPONDING wa_migo TO wa_error.
wa_error-message = 'PO Mark for Deletion'.
DELETE it_migo INDEX lv_index.
ENDIF.
ENDIF.
IF wa_ekpo-loekz EQ 'X'.
MOVE-CORRESPONDING wa_migo TO wa_error.
wa_error-message = 'PO Mark for Deletion'.
DELETE it_migo INDEX lv_index.
ENDIF.
ELSE.
MOVE-CORRESPONDING wa_migo TO wa_error.
wa_error-message = 'PO not found'.
DELETE it_migo INDEX lv_index.
ENDIF.
APPEND wa_error TO it_error.
*--Clear
CLEAR : wa_error,
wa_migo,
wa_ekpo.
ENDLOOP.
ENDIF.
ENDFORM. " sub_validate_data
&----
*& Form sub_download_data
&----
text
----
FORM sub_download_data .
*--Local Variables
DATA : lv_error TYPE string.
lv_error = p_error.
IF NOT it_error[] IS INITIAL AND
NOT lv_error IS INITIAL.
*--Call function module to download the errors on file
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = lv_error
filetype = 'ASC'
write_field_separator = 'X'
TABLES
data_tab = it_error
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDFORM. " sub_download_data
&----
*& Form sub_transfer_data
&----
text
----
FORM sub_transfer_data .
*--Call function odule to open the session
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
client = sy-mandt
group = p_sesn
keep = 'X'
user = sy-uname
prog = sy-cprog
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.
ENDFORM. " sub_transfer_data
&----
*& Form sub_bdc_session
&----
text
----
FORM sub_bdc_session .
IF NOT it_migo[] IS INITIAL.
LOOP AT it_migo INTO wa_migo.
AT NEW po_number.
v_flag = 'X'.
ENDAT.
AT END OF po_number.
v_last_flag = 'X'.
ENDAT.
IF v_flag = 'X'.
v_cnt = '1'.
PERFORM bdc_dynpro USING 'SAPLMIGO' '0001'.
PERFORM bdc_field USING 'BDC_OKCODE' '=OK_GO'.
PERFORM bdc_field USING 'GODYNPRO-ACTION' 'A01'.
PERFORM bdc_field USING 'GODYNPRO-REFDOC' 'R01'.
PERFORM bdc_field USING 'GODEFAULT_TV-BWART' '101'.
PERFORM bdc_field USING 'BDC_CURSOR' 'GODYNPRO-PO_NUMBER'.
PERFORM bdc_field USING 'GODYNPRO-PO_NUMBER' wa_migo-po_number. "'4500017122'.
PERFORM bdc_field USING 'GOHEAD-BLDAT' wa_migo-doc_date. "'07.06.2007'.
PERFORM bdc_field USING 'GOHEAD-BUDAT' wa_migo-post_date. " '07.06.2007'.
PERFORM bdc_field USING 'GOHEAD-WEVER' '1'.
ENDIF.
PERFORM bdc_dynpro USING 'SAPLMIGO' '0001'.
PERFORM bdc_field USING 'BDC_OKCODE' '=OK_GO'.
PERFORM bdc_field USING 'GODEFAULT_TV-BWART' '101'.
PERFORM bdc_field USING 'BDC_CURSOR' 'GOHEAD-BKTXT'.
PERFORM bdc_field USING 'GOHEAD-LFSNR' wa_migo-del_note. "'4500017122'.
PERFORM bdc_field USING 'GOHEAD-FRBNR' wa_migo-bill_lad. "'Testing'.
PERFORM bdc_field USING 'GOHEAD-BKTXT' wa_migo-head_txt. "'4500017122'.
PERFORM bdc_field USING 'GOHEAD-WEVER' '1'.
PERFORM bdc_field USING 'GODYNPRO-DETAIL_ZEILE' v_cnt. "' 1'.
PERFORM bdc_field USING 'GOITEM-ERFME' 'PC'.
PERFORM bdc_field USING 'GOITEM-ERFMG' '10'.
PERFORM bdc_field USING 'GOITEM-MIGO_ELIKZ' '1'.
PERFORM bdc_field USING 'GOITEM-BWART' '101'.
PERFORM bdc_field USING 'GOITEM-LGOBE' wa_migo-lgort. "'Materiallager'.
PERFORM bdc_field USING 'WMS_MIGO_0100-LMEN1' '1'.
PERFORM bdc_field USING 'WMS_MIGO_0100-LETY1' 'BX1'.
PERFORM bdc_field USING 'WMS_MIGO_0100-ANZL1' '10'.
PERFORM bdc_dynpro USING 'SAPLMIGO' '0001'.
PERFORM bdc_field USING 'BDC_OKCODE' '=OK_GO'.
PERFORM bdc_field USING 'GODEFAULT_TV-BWART' '101'.
PERFORM bdc_field USING 'BDC_CURSOR' 'GOITEM-LSMNG'.
PERFORM bdc_field USING 'GOITEM-ERFMG' wa_migo-qty. "'1'.
PERFORM bdc_field USING 'GOITEM-LSMNG' wa_migo-qty_note. "'1'.
PERFORM bdc_field USING 'GOITEM-MIGO_ELIKZ' '1'.
PERFORM bdc_field USING 'GOITEM-BWART' '101'.
PERFORM bdc_field USING 'WMS_MIGO_0100-LMEN1' '1'.
PERFORM bdc_field USING 'WMS_MIGO_0100-LETY1' 'BX1'.
PERFORM bdc_field USING 'WMS_MIGO_0100-ANZL1' '10'.
PERFORM bdc_dynpro USING 'SAPLMIGO' '0001'.
PERFORM bdc_field USING 'BDC_OKCODE' '=OK_GO'.
PERFORM bdc_field USING 'GODEFAULT_TV-BWART' '101'.
PERFORM bdc_field USING 'GOHEAD-WEVER' '1'.
PERFORM bdc_field USING 'GODYNPRO-DETAIL_ZEILE' v_cnt. "' 1'.
PERFORM bdc_field USING 'GOITEM-ERFME' 'PC'.
PERFORM bdc_field USING 'WMS_MIGO_0100-LMEN1' '1'.
PERFORM bdc_field USING 'WMS_MIGO_0100-LETY1' 'BX1'.
PERFORM bdc_field USING 'WMS_MIGO_0100-ANZL1' '5'.
PERFORM bdc_dynpro USING 'SAPLMIGO' '0001'.
PERFORM bdc_field USING 'BDC_OKCODE' '=MIGO_OK_SHIP_CONS'.
PERFORM bdc_field USING 'GODEFAULT_TV-BWART' '101'.
PERFORM bdc_field USING 'GOHEAD-WEVER' '1'.
PERFORM bdc_field USING 'GODYNPRO-DETAIL_ZEILE' v_cnt. "' 1'.
PERFORM bdc_field USING 'GOITEM-ERFME' 'PC'.
PERFORM bdc_field USING 'BDC_CURSOR' 'GOITEM-EBELN'.
PERFORM bdc_field USING 'GOITEM-MIGO_ELIKZ' '1'.
PERFORM bdc_field USING 'GOITEM-BWART' '101'.
PERFORM bdc_field USING 'WMS_MIGO_0100-LMEN1' '1'.
PERFORM bdc_field USING 'WMS_MIGO_0100-LETY1' 'BX1'.
PERFORM bdc_field USING 'WMS_MIGO_0100-ANZL1' '5'.
PERFORM bdc_dynpro USING 'SAPLEINQ' '0100'.
PERFORM bdc_field USING 'BDC_CURSOR' 'T027A-EVERS'.
PERFORM bdc_field USING 'BDC_OKCODE' '=ENTE'.
PERFORM bdc_dynpro USING 'SAPLMIGO' '0001'.
PERFORM bdc_field USING 'BDC_OKCODE' '=OK_CHECK'.
PERFORM bdc_field USING 'GODEFAULT_TV-BWART' '101'.
PERFORM bdc_field USING 'GOHEAD-WEVER' '1'.
PERFORM bdc_field USING 'GODYNPRO-DETAIL_ZEILE' v_cnt. "' 1'..
PERFORM bdc_field USING 'GOITEM-ERFME' 'PC'.
PERFORM bdc_field USING 'GOITEM-MIGO_ELIKZ' '1'.
PERFORM bdc_field USING 'GOITEM-BWART' '101'.
PERFORM bdc_field USING 'WMS_MIGO_0100-LMEN1' '1'.
PERFORM bdc_field USING 'WMS_MIGO_0100-LETY1' 'BX1'.
PERFORM bdc_field USING 'WMS_MIGO_0100-ANZL1' '5'.
PERFORM bdc_field USING 'BDC_CURSOR' 'GODYNPRO-DETAIL_TAKE'.
PERFORM bdc_field USING 'GODYNPRO-DETAIL_TAKE' 'X'.
PERFORM bdc_dynpro USING 'SAPMSSY0' '0120'.
PERFORM bdc_field USING 'BDC_CURSOR' '01/02'.
PERFORM bdc_field USING 'BDC_OKCODE' '=&ONT'.
IF v_last_flag = 'X'.
PERFORM bdc_dynpro USING 'SAPLMIGO' '0001'.
PERFORM bdc_field USING 'BDC_OKCODE' '=OK_POST1'.
PERFORM sub_bdc_insert.
REFRESH it_bdc_data.
ENDIF.
v_cnt = v_cnt + 1.
*--Clear
CLEAR : v_flag,
v_last_flag.
ENDLOOP.
ENDIF.
ENDFORM. " sub_bdc_session
----
Start new screen *
----
FORM bdc_dynpro USING program dynpro.
*--Clear
CLEAR : it_bdc_data.
it_bdc_data-program = program.
it_bdc_data-dynpro = dynpro.
it_bdc_data-dynbegin = 'X'.
APPEND it_bdc_data.
ENDFORM.
----
Insert field *
----
FORM bdc_field USING fnam fval.
IF fval <> nodata.
*--Clear
CLEAR : it_bdc_data.
it_bdc_data-fnam = fnam.
it_bdc_data-fval = fval.
APPEND it_bdc_data.
ENDIF.
ENDFORM.
&----
*& Form sub_bdc_insert
&----
text
----
FORM sub_bdc_insert .
*--Call function module to insert the data into sap system
CALL FUNCTION 'BDC_INSERT'
EXPORTING
tcode = 'MIGO'
TABLES
dynprotab = it_bdc_data
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.
ENDFORM. " sub_bdc_insert
&----
*& Form sub_close_group
&----
text
----
FORM sub_close_group .
*--Call function module to close the session
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.
ENDFORM. " sub_close_group
&----
*& Form sub_call_transaction
&----
text
----
FORM sub_call_transaction .
IF NOT it_migo[] IS INITIAL.
LOOP AT it_migo INTO wa_migo.
AT NEW po_number.
v_flag = 'X'.
ENDAT.
AT END OF po_number.
v_last_flag = 'X'.
ENDAT.
IF v_flag = 'X'.
v_cnt = '1'.
PERFORM bdc_dynpro USING 'SAPLMIGO' '0001'.
PERFORM bdc_field USING 'BDC_OKCODE' '=OK_GO'.
PERFORM bdc_field USING 'GODYNPRO-ACTION' 'A01'.
PERFORM bdc_field USING 'GODYNPRO-REFDOC' 'R01'.
PERFORM bdc_field USING 'GODEFAULT_TV-BWART' '101'.
PERFORM bdc_field USING 'BDC_CURSOR' 'GODYNPRO-PO_NUMBER'.
PERFORM bdc_field USING 'GODYNPRO-PO_NUMBER' wa_migo-po_number. "'4500017122'.
PERFORM bdc_field USING 'GOHEAD-BLDAT' wa_migo-doc_date. "'07.06.2007'.
PERFORM bdc_field USING 'GOHEAD-BUDAT' wa_migo-post_date. " '07.06.2007'.
PERFORM bdc_field USING 'GOHEAD-WEVER' '1'.
ENDIF.
PERFORM bdc_dynpro USING 'SAPLMIGO' '0001'.
PERFORM bdc_field USING 'BDC_OKCODE' '=OK_GO'.
PERFORM bdc_field USING 'GODEFAULT_TV-BWART' '101'.
PERFORM bdc_field USING 'BDC_CURSOR' 'GOHEAD-BKTXT'.
PERFORM bdc_field USING 'GOHEAD-LFSNR' wa_migo-del_note. "'4500017122'.
PERFORM bdc_field USING 'GOHEAD-FRBNR' wa_migo-bill_lad. "'Testing'.
PERFORM bdc_field USING 'GOHEAD-BKTXT' wa_migo-head_txt. "'4500017122'.
PERFORM bdc_field USING 'GOHEAD-WEVER' '1'.
PERFORM bdc_field USING 'GODYNPRO-DETAIL_ZEILE' v_cnt. "' 1'.
PERFORM bdc_field USING 'GOITEM-ERFME' 'PC'.
PERFORM bdc_field USING 'GOITEM-ERFMG' '10'.
PERFORM bdc_field USING 'GOITEM-MIGO_ELIKZ' '1'.
PERFORM bdc_field USING 'GOITEM-BWART' '101'.
PERFORM bdc_field USING 'GOITEM-LGOBE' wa_migo-lgort. "'Materiallager'.
PERFORM bdc_field USING 'WMS_MIGO_0100-LMEN1' '1'.
PERFORM bdc_field USING 'WMS_MIGO_0100-LETY1' 'BX1'.
PERFORM bdc_field USING 'WMS_MIGO_0100-ANZL1' '10'.
PERFORM bdc_dynpro USING 'SAPLMIGO' '0001'.
PERFORM bdc_field USING 'BDC_OKCODE' '=OK_GO'.
PERFORM bdc_field USING 'GODEFAULT_TV-BWART' '101'.
PERFORM bdc_field USING 'BDC_CURSOR' 'GOITEM-LSMNG'.
PERFORM bdc_field USING 'GOITEM-ERFMG' wa_migo-qty. "'1'.
PERFORM bdc_field USING 'GOITEM-LSMNG' wa_migo-qty_note. "'1'.
PERFORM bdc_field USING 'GOITEM-MIGO_ELIKZ' '1'.
PERFORM bdc_field USING 'GOITEM-BWART' '101'.
PERFORM bdc_field USING 'WMS_MIGO_0100-LMEN1' '1'.
PERFORM bdc_field USING 'WMS_MIGO_0100-LETY1' 'BX1'.
PERFORM bdc_field USING 'WMS_MIGO_0100-ANZL1' '10'.
PERFORM bdc_dynpro USING 'SAPLMIGO' '0001'.
PERFORM bdc_field USING 'BDC_OKCODE' '=OK_GO'.
PERFORM bdc_field USING 'GODEFAULT_TV-BWART' '101'.
PERFORM bdc_field USING 'GOHEAD-WEVER' '1'.
PERFORM bdc_field USING 'GODYNPRO-DETAIL_ZEILE' v_cnt. "' 1'.
PERFORM bdc_field USING 'GOITEM-ERFME' 'PC'.
PERFORM bdc_field USING 'WMS_MIGO_0100-LMEN1' '1'.
PERFORM bdc_field USING 'WMS_MIGO_0100-LETY1' 'BX1'.
PERFORM bdc_field USING 'WMS_MIGO_0100-ANZL1' '5'.
PERFORM bdc_dynpro USING 'SAPLMIGO' '0001'.
PERFORM bdc_field USING 'BDC_OKCODE' '=MIGO_OK_SHIP_CONS'.
PERFORM bdc_field USING 'GODEFAULT_TV-BWART' '101'.
PERFORM bdc_field USING 'GOHEAD-WEVER' '1'.
PERFORM bdc_field USING 'GODYNPRO-DETAIL_ZEILE' v_cnt. "' 1'.
PERFORM bdc_field USING 'GOITEM-ERFME' 'PC'.
PERFORM bdc_field USING 'BDC_CURSOR' 'GOITEM-EBELN'.
PERFORM bdc_field USING 'GOITEM-MIGO_ELIKZ' '1'.
PERFORM bdc_field USING 'GOITEM-BWART' '101'.
PERFORM bdc_field USING 'WMS_MIGO_0100-LMEN1' '1'.
PERFORM bdc_field USING 'WMS_MIGO_0100-LETY1' 'BX1'.
PERFORM bdc_field USING 'WMS_MIGO_0100-ANZL1' '5'.
PERFORM bdc_dynpro USING 'SAPLEINQ' '0100'.
PERFORM bdc_field USING 'BDC_CURSOR' 'T027A-EVERS'.
PERFORM bdc_field USING 'BDC_OKCODE' '=ENTE'.
PERFORM bdc_dynpro USING 'SAPLMIGO' '0001'.
PERFORM bdc_field USING 'BDC_OKCODE' '=OK_CHECK'.
PERFORM bdc_field USING 'GODEFAULT_TV-BWART' '101'.
PERFORM bdc_field USING 'GOHEAD-WEVER' '1'.
PERFORM bdc_field USING 'GODYNPRO-DETAIL_ZEILE' v_cnt. "' 1'..
PERFORM bdc_field USING 'GOITEM-ERFME' 'PC'.
PERFORM bdc_field USING 'GOITEM-MIGO_ELIKZ' '1'.
PERFORM bdc_field USING 'GOITEM-BWART' '101'.
PERFORM bdc_field USING 'WMS_MIGO_0100-LMEN1' '1'.
PERFORM bdc_field USING 'WMS_MIGO_0100-LETY1' 'BX1'.
PERFORM bdc_field USING 'WMS_MIGO_0100-ANZL1' '5'.
PERFORM bdc_field USING 'BDC_CURSOR' 'GODYNPRO-DETAIL_TAKE'.
PERFORM bdc_field USING 'GODYNPRO-DETAIL_TAKE' 'X'.
PERFORM bdc_dynpro USING 'SAPMSSY0' '0120'.
PERFORM bdc_field USING 'BDC_CURSOR' '01/02'.
PERFORM bdc_field USING 'BDC_OKCODE' '=&ONT'.
IF v_last_flag = 'X'.
PERFORM bdc_dynpro USING 'SAPLMIGO' '0001'.
PERFORM bdc_field USING 'BDC_OKCODE' '=OK_POST1'.
PERFORM sub_bdc_tcode.
REFRESH it_bdc_data.
ENDIF.
v_cnt = v_cnt + 1.
*--Clear
CLEAR : v_flag,
v_last_flag.
ENDLOOP.
ENDIF.
ENDFORM. " sub_call_transaction
&----
*& Form sub_bdc_tcode
&----
text
----
FORM sub_bdc_tcode .
CALL TRANSACTION 'MIGO'
USING it_bdc_data
MODE 'A'
UPDATE 'A'.
ENDFORM. " sub_bdc_tcode
Reward if usefull
Regards,
Prashant
11-27-2007 8:58 AM