2008 Apr 22 2:02 AM
hi gurus,
i am trying to do a material master creation using BDC recording,
i am new i dont know how to modify the code,
the following is the code generated through recording through SHDB,
please let me know how to make changes, to modify for our requirement.
report ZTEST95
no standard page heading line-size 255.
include bdcrecx1.
parameters: dataset(132) lower case default
'C:\Documents and Settings\Deskt'
& 'op\test95.txt'.
data: begin of record,
MATNR_001(040),
MBRSH_002(001),
MTART_003(004),
MATNR_004(040),
KZSEL_01_005(001),
MAKTX_006(040),
MEINS_007(003),
MATKL_008(009),
SPART_009(002),
MTPOS_MARA_010(004),
BRGEW_011(017),
GEWEI_012(003),
NTGEW_013(017),
end of record.
start-of-selection.
perform open_dataset using dataset.
perform open_group.
do.
read dataset dataset into record.
if sy-subrc 0. exit. endif.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'RMMG1-MATNR'
record-MATNR_001.
perform bdc_field using 'RMMG1-MBRSH'
record-MBRSH_002.
perform bdc_field using 'RMMG1-MTART'
record-MTART_003.
perform bdc_field using 'RMMG1_REF-MATNR'
record-MATNR_004.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
record-KZSEL_01_005.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MAKT-MAKTX'
record-MAKTX_006.
perform bdc_field using 'MARA-MEINS'
record-MEINS_007.
perform bdc_field using 'MARA-MATKL'
record-MATKL_008.
perform bdc_field using 'MARA-SPART'
record-SPART_009.
perform bdc_field using 'MARA-MTPOS_MARA'
record-MTPOS_MARA_010.
perform bdc_field using 'BDC_CURSOR'
'MARA-BRGEW'.
perform bdc_field using 'MARA-BRGEW'
record-BRGEW_011.
perform bdc_field using 'MARA-GEWEI'
record-GEWEI_012.
perform bdc_field using 'MARA-NTGEW'
record-NTGEW_013.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
perform bdc_transaction using 'MM01'.
enddo.
perform close_group.
perform close_dataset using dataset.
thanks.
Edited by: sanjana on Apr 22, 2008 3:03 AM
hi gurus,
i am trying to do a material master creation using BDC recording,
i am new i dont know how to modify the code,
the following is the code generated through recording through SHDB,
please let me know how to make changes, to modify for our requirement.
report ZTEST95
no standard page heading line-size 255.
include bdcrecx1.
parameters: dataset(132) lower case default
'C:\Documents and Settings\Deskt'
& 'op\test95.txt'.
data: begin of record,
MATNR_001(040),
MBRSH_002(001),
MTART_003(004),
MATNR_004(040),
KZSEL_01_005(001),
MAKTX_006(040),
MEINS_007(003),
MATKL_008(009),
SPART_009(002),
MTPOS_MARA_010(004),
BRGEW_011(017),
GEWEI_012(003),
NTGEW_013(017),
end of record.
start-of-selection.
perform open_dataset using dataset.
perform open_group.
do.
read dataset dataset into record.
if sy-subrc 0. exit. endif.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'RMMG1-MATNR'
record-MATNR_001.
perform bdc_field using 'RMMG1-MBRSH'
record-MBRSH_002.
perform bdc_field using 'RMMG1-MTART'
record-MTART_003.
perform bdc_field using 'RMMG1_REF-MATNR'
record-MATNR_004.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
record-KZSEL_01_005.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MAKT-MAKTX'
record-MAKTX_006.
perform bdc_field using 'MARA-MEINS'
record-MEINS_007.
perform bdc_field using 'MARA-MATKL'
record-MATKL_008.
perform bdc_field using 'MARA-SPART'
record-SPART_009.
perform bdc_field using 'MARA-MTPOS_MARA'
record-MTPOS_MARA_010.
perform bdc_field using 'BDC_CURSOR'
'MARA-BRGEW'.
perform bdc_field using 'MARA-BRGEW'
record-BRGEW_011.
perform bdc_field using 'MARA-GEWEI'
record-GEWEI_012.
perform bdc_field using 'MARA-NTGEW'
record-NTGEW_013.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
perform bdc_transaction using 'MM01'.
enddo.
perform close_group.
perform close_dataset using dataset.
thanks.
Edited by: sanjana on Apr 22, 2008 3:03 AM
2008 Apr 22 3:02 AM
actually u r question is not clear.
any how i will give the process for any transaction.
step 1: observe the transaction and all field names.
step 2 : populate the data into internal table.
start-of-selection.
step 3: loop at internal table.
screen 1: call that particular screen using its program name and screen num.
ex: perform bdc_dynpro using 'SAPLMGMM' '0060'.
in this screen which field u wan to fill........
filll that filed like below
ex:perform bdc_field using 'RMMG1-MATNR'
record-MATNR_001.
.
..
.
.
like this in that perticulat screen fill all fields.
then use ok code like below....
ex: perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
now one screen finished.....
now call second screen.......
like this u can write the program.
note: first take recording but dont put that program blidly into ui r program...analy all the lines like this..screen by screen.....then u can understand easily.......
Thanks & Regards,
khasimsa
endloop.
2008 Apr 22 5:08 AM
Hi Sanjana,
Here i am giving the sample code for BDC Recording (Material Master).After See this you may get the idea how to change the code.
report ZSAM_BDC_CT_RECORD_25OCT no standard page heading line-size 255.
*include bdcrecx1.
&----
Structure declaration
&----
TYPES : BEGIN OF TY_MM01,
MATNR TYPE MATNR,
MBRSH TYPE MBRSH,
MTART TYPE MTART,
MAKTX TYPE MAKTX,
MEINS TYPE MEINS,
END OF TY_MM01.
&----
Internal table & workarea declaration
&----
data : w_mm01 type ty_mm01,
t_mm01 type table of ty_mm01.
data : bdcdata type bdcdata occurs 0 with header line.
data : nodata type c.
start-of-selection.
&----
Internal table & workarea declaration
&----
call function 'GUI_UPLOAD'
exporting
filename = 'D:\Documents and Settings\nzd44b\Desktop\sample1.txt'
FILETYPE = 'ASC'
tables
data_tab = t_mm01.
loop at t_mm01 into w_mm01.
fIRST SCREEN *
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RMMG1-MATNR'
w_mm01-matnr.
perform bdc_field using 'RMMG1-MBRSH'
w_mm01-mbrsh.
perform bdc_field using 'RMMG1-MTART'
w_mm01-mtart.
SECOND SCREEN *
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
'X'.
THIRD SCREEN *
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MAKT-MAKTX'
w_mm01-maktx.
perform bdc_field using 'MARA-MEINS'
w_mm01-meins.
fOURTH SCREEN *
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
*perform bdc_transaction using 'MM01'.
CALL TRANSACTION 'MM01' USING BDCDATA MODE 'A' UPDATE 'S'.
endloop.
----
Start new screen
----
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
ENDFORM.
----
Insert field
----
FORM BDC_FIELD USING FNAM FVAL.
IF FVAL <> NODATA.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
ENDIF.
ENDFORM.
Reward if it Useful..
Edited by: lakshmi matti on Apr 22, 2008 6:09 AM
Edited by: lakshmi matti on Apr 22, 2008 6:14 AM
2008 Apr 22 5:11 AM
hi
its better to check the radiobutton transfer from recording,
you must pass the internal table fields where ever you passed the values in recording
see the following code its done for mm01 with basic data1 and basic data2 you can understand clearly
REPORT zp_recording
NO STANDARD PAGE HEADING LINE-SIZE 255.
INCLUDE bdcrecx1.
TYPES: BEGIN OF ty_mara,
matnr LIKE mara-matnr,
mbrsh LIKE mara-mbrsh,
mtart LIKE mara-mtart,
maktx LIKE makt-maktx,
meins LIKE mara-meins,
END OF ty_mara.
DATA: it_mara TYPE TABLE OF ty_mara WITH HEADER LINE.
PARAMETERS : p_file TYPE ibipparms-path.
DATA v_file TYPE string.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
file_name = p_file.
START-OF-SELECTION.
MOVE p_file TO v_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = v_file
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = it_mara.
PERFORM open_group.
LOOP AT it_mara.
PERFORM bdc_dynpro USING 'SAPLMGMM' '0060'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RMMG1-MATNR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'RMMG1-MATNR'
it_mara-matnr.
PERFORM bdc_field USING 'RMMG1-MBRSH'
it_mara-mbrsh.
PERFORM bdc_field USING 'RMMG1-MTART'
it_mara-mtart.
PERFORM bdc_dynpro USING 'SAPLMGMM' '0070'.
PERFORM bdc_field USING 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(02)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
PERFORM bdc_field USING 'MSICHTAUSW-KZSEL(01)'
'X'.
PERFORM bdc_field USING 'MSICHTAUSW-KZSEL(02)'
'X'.
PERFORM bdc_dynpro USING 'SAPLMGMM' '4004'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'MAKT-MAKTX'
it_mara-maktx.
PERFORM bdc_field USING 'BDC_CURSOR'
'MARA-MEINS'.
PERFORM bdc_field USING 'MARA-MEINS'
it_mara-meins.
PERFORM bdc_field USING 'MARA-MTPOS_MARA'
'VOLL'.
PERFORM bdc_dynpro USING 'SAPLMGMM' '4004'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BDC_CURSOR'
'MAKT-MAKTX'.
PERFORM bdc_field USING 'MAKT-MAKTX'
it_mara-maktx.
PERFORM bdc_dynpro USING 'SAPLSPO1' '0300'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=YES'.
perform bdc_transaction using 'MM01'.
ENDLOOP.
PERFORM close_group.
2008 Apr 22 5:35 AM
Hi
After creating your recording in shdb, you will get the file structure as of how your file is to be uploaded to sap systems.
Now if your file is in workstation, you have to use the functions like open-group and close-group. Suppose if your file is in application server you have to use the functions like open-dataset, read-dataset and close-dataset.
For example, consider that your program is in workstation.
You have to make changes like:
1) Include occurs 10 to make the structure record into an internal table.
2) Comment the statements including open- dataset, read-dataset and close-dataset.
3) Call the function gui_upload after the start-of-selection.
4) In that function you have to specify the filename, filetype, file-seperatorand in tables write your internal table name.
5) Instead of do .enddo statement, write Loop at record ..endloop.
6) Save, activate and execute.
report ZTEST95
no standard page heading line-size 255.
include bdcrecx1.
parameters: dataset(132) lower case default
'C:\Documents and Settings\Deskt'
& 'op\test95.txt'.
data: begin of record occurs 10,
MATNR_001(040),
MBRSH_002(001),
MTART_003(004),
MATNR_004(040),
KZSEL_01_005(001),
MAKTX_006(040),
MEINS_007(003),
MATKL_008(009),
SPART_009(002),
MTPOS_MARA_010(004),
BRGEW_011(017),
GEWEI_012(003),
NTGEW_013(017),
end of record.
start-of-selection.
call function gui_upload
..
*perform open_dataset using dataset.
perform open_group.
loop at record.
*read dataset dataset into record.
if sy-subrc 0. exit. endif.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'RMMG1-MATNR'
record-MATNR_001.
perform bdc_field using 'RMMG1-MBRSH'
record-MBRSH_002.
perform bdc_field using 'RMMG1-MTART'
record-MTART_003.
perform bdc_field using 'RMMG1_REF-MATNR'
record-MATNR_004.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
record-KZSEL_01_005.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MAKT-MAKTX'
record-MAKTX_006.
perform bdc_field using 'MARA-MEINS'
record-MEINS_007.
perform bdc_field using 'MARA-MATKL'
record-MATKL_008.
perform bdc_field using 'MARA-SPART'
record-SPART_009.
perform bdc_field using 'MARA-MTPOS_MARA'
record-MTPOS_MARA_010.
perform bdc_field using 'BDC_CURSOR'
'MARA-BRGEW'.
perform bdc_field using 'MARA-BRGEW'
record-BRGEW_011.
perform bdc_field using 'MARA-GEWEI'
record-GEWEI_012.
perform bdc_field using 'MARA-NTGEW'
record-NTGEW_013.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
perform bdc_transaction using 'MM01'.
endloop.
perform close_group.
*perform close_dataset using dataset.
2008 Apr 22 6:03 AM
hi,
i made the changes please check it
&----
*& Report ZBDC
*&
&----
*&
*&
&----
report ZTEST95
no standard page heading line-size 255.
include bdcrecx1.
parameters: dataset(132) lower case default
'C:\Documents and Settings\Deskt'
& 'op\test95.txt'.
data: begin of record,
MATNR_001(040),
MBRSH_002(001),
MTART_003(004),
MATNR_004(040),
KZSEL_01_005(001),
MAKTX_006(040),
MEINS_007(003),
MATKL_008(009),
SPART_009(002),
MTPOS_MARA_010(004),
BRGEW_011(017),
GEWEI_012(003),
NTGEW_013(017),
end of record.
start-of-selection.
perform open_dataset using dataset.
perform open_group.
do.
read dataset dataset into record.
*if sy-subrc 0. exit. endif.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'RMMG1-MATNR'
record-MATNR_001.
perform bdc_field using 'RMMG1-MBRSH'
record-MBRSH_002.
perform bdc_field using 'RMMG1-MTART'
record-MTART_003.
perform bdc_field using 'RMMG1_REF-MATNR'
record-MATNR_004.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
record-KZSEL_01_005.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MAKT-MAKTX'
record-MAKTX_006.
perform bdc_field using 'MARA-MEINS'
record-MEINS_007.
perform bdc_field using 'MARA-MATKL'
record-MATKL_008.
perform bdc_field using 'MARA-SPART'
record-SPART_009.
perform bdc_field using 'MARA-MTPOS_MARA'
record-MTPOS_MARA_010.
perform bdc_field using 'BDC_CURSOR'
'MARA-BRGEW'.
perform bdc_field using 'MARA-BRGEW'
record-BRGEW_011.
perform bdc_field using 'MARA-GEWEI'
record-GEWEI_012.
perform bdc_field using 'MARA-NTGEW'
record-NTGEW_013.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
perform bdc_transaction using 'MM01'.
enddo.
perform close_group.
perform close_dataset using dataset.
2008 Apr 22 6:07 AM
hi ,
look at this sample program.
REPORT ZSTEST_048 .
DATA: BEGIN OF ITAB OCCURS 0,
LIFNR(10) TYPE C,
F1(4) TYPE C,
F2(4) TYPE C,
F3(4) TYPE C,
F4(10) TYPE C,
F5(35) TYPE C,
F6(10) TYPE C,
F7(3) TYPE C,
F8(10) TYPE C,
F9(10) TYPE C,
F10(3) TYPE C,
END OF ITAB.
DATA FILE TYPE STRING.
DATA I_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
START-OF-SELECTION.
FILE = 'C:\Documents and Settings\AMS\Desktop\VENDOR.TXT'.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = FILE
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = ' '
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = ITAB
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 ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
END-OF-SELECTION.
LOOP AT ITAB.
*--100
I_BDCDATA-PROGRAM = 'SAPMF02K'.
I_BDCDATA-DYNPRO = '0100'.
I_BDCDATA-DYNBEGIN = 'X'.
APPEND I_BDCDATA.
CLEAR I_BDCDATA.
I_BDCDATA-FNAM = 'RF02K-LIFNR'.
I_BDCDATA-FVAL = ITAB-LIFNR.
APPEND I_BDCDATA.
CLEAR I_BDCDATA.
I_BDCDATA-FNAM = 'RF02K-BUKRS'.
I_BDCDATA-FVAL = ITAB-F1.
APPEND I_BDCDATA.
CLEAR I_BDCDATA.
I_BDCDATA-FNAM = 'RF02K-EKORG'.
I_BDCDATA-FVAL = ITAB-F2.
APPEND I_BDCDATA.
CLEAR I_BDCDATA.
I_BDCDATA-FNAM = 'RF02K-KTOKK'.
I_BDCDATA-FVAL = ITAB-F3.
APPEND I_BDCDATA.
CLEAR I_BDCDATA.
I_BDCDATA-FNAM = 'BDC_OKCODE'.
I_BDCDATA-FVAL = '/00'.
APPEND I_BDCDATA.
CLEAR I_BDCDATA.
*--110
I_BDCDATA-PROGRAM = 'SAPMF02K'.
I_BDCDATA-DYNPRO = '0110'.
I_BDCDATA-DYNBEGIN = 'X'.
APPEND I_BDCDATA.
CLEAR I_BDCDATA.
I_BDCDATA-FNAM = 'LFA1-ANRED'.
I_BDCDATA-FVAL = ITAB-F4.
APPEND I_BDCDATA.
CLEAR I_BDCDATA.
I_BDCDATA-FNAM = 'LFA1-NAME1'.
I_BDCDATA-FVAL = ITAB-F5.
APPEND I_BDCDATA.
CLEAR I_BDCDATA.
I_BDCDATA-FNAM = 'LFA1-SORTL'.
I_BDCDATA-FVAL = ITAB-F6.
APPEND I_BDCDATA.
CLEAR I_BDCDATA.
I_BDCDATA-FNAM = 'LFA1-LAND1'.
I_BDCDATA-FVAL = ITAB-F7.
APPEND I_BDCDATA.
CLEAR I_BDCDATA.
I_BDCDATA-FNAM = 'BDC_OKCODE'.
I_BDCDATA-FVAL = '/00'.
APPEND I_BDCDATA.
CLEAR I_BDCDATA.
*--120
I_BDCDATA-PROGRAM = 'SAPMF02K'.
I_BDCDATA-DYNPRO = '0120'.
I_BDCDATA-DYNBEGIN = 'X'.
APPEND I_BDCDATA.
CLEAR I_BDCDATA.
I_BDCDATA-FNAM = 'BDC_OKCODE'.
I_BDCDATA-FVAL = '/00'.
APPEND I_BDCDATA.
CLEAR I_BDCDATA.
*--130
I_BDCDATA-PROGRAM = 'SAPMF02K'.
I_BDCDATA-DYNPRO = '0130'.
I_BDCDATA-DYNBEGIN = 'X'.
APPEND I_BDCDATA.
CLEAR I_BDCDATA.
I_BDCDATA-FNAM = 'BDC_OKCODE'.
I_BDCDATA-FVAL = '=ENTR'.
APPEND I_BDCDATA.
CLEAR I_BDCDATA.
*--210
I_BDCDATA-PROGRAM = 'SAPMF02K'.
I_BDCDATA-DYNPRO = '0210'.
I_BDCDATA-DYNBEGIN = 'X'.
APPEND I_BDCDATA.
CLEAR I_BDCDATA.
I_BDCDATA-FNAM = 'LFB1-AKONT'.
I_BDCDATA-FVAL = ITAB-F8.
APPEND I_BDCDATA.
CLEAR I_BDCDATA.
I_BDCDATA-FNAM = 'LFB1-FDGRV'.
I_BDCDATA-FVAL = ITAB-F9.
APPEND I_BDCDATA.
CLEAR I_BDCDATA.
I_BDCDATA-FNAM = 'BDC_OKCODE'.
I_BDCDATA-FVAL = '/00'.
APPEND I_BDCDATA.
CLEAR I_BDCDATA.
*--0215
I_BDCDATA-PROGRAM = 'SAPMF02K'.
I_BDCDATA-DYNPRO = '0215'.
I_BDCDATA-DYNBEGIN = 'X'.
APPEND I_BDCDATA.
CLEAR I_BDCDATA.
I_BDCDATA-FNAM = 'BDC_OKCODE'.
I_BDCDATA-FVAL = '/00'.
APPEND I_BDCDATA.
CLEAR I_BDCDATA.
*-- 220
I_BDCDATA-PROGRAM = 'SAPMF02K'.
I_BDCDATA-DYNPRO = '0220'.
I_BDCDATA-DYNBEGIN = 'X'.
APPEND I_BDCDATA.
CLEAR I_BDCDATA.
I_BDCDATA-FNAM = 'BDC_OKCODE'.
I_BDCDATA-FVAL = '/00'.
APPEND I_BDCDATA.
CLEAR I_BDCDATA.
*--310
I_BDCDATA-PROGRAM = 'SAPMF02K'.
I_BDCDATA-DYNPRO = '0310'.
I_BDCDATA-DYNBEGIN = 'X'.
APPEND I_BDCDATA.
CLEAR I_BDCDATA.
I_BDCDATA-FNAM = 'LFM1-WAERS'.
I_BDCDATA-FVAL = ITAB-F10.
APPEND I_BDCDATA.
CLEAR I_BDCDATA.
I_BDCDATA-FNAM = 'BDC_OKCODE'.
I_BDCDATA-FVAL = '/00'.
APPEND I_BDCDATA.
CLEAR I_BDCDATA.
*--0320
I_BDCDATA-PROGRAM = 'SAPMF02K'.
I_BDCDATA-DYNPRO = '0320'.
I_BDCDATA-DYNBEGIN = 'X'.
APPEND I_BDCDATA.
CLEAR I_BDCDATA.
I_BDCDATA-FNAM = 'BDC_OKCODE'.
I_BDCDATA-FVAL = '=ENTR'.
APPEND I_BDCDATA.
CLEAR I_BDCDATA.
*--330
I_BDCDATA-PROGRAM = 'SAPLSPO1'.
I_BDCDATA-DYNPRO = '0330'.
I_BDCDATA-DYNBEGIN = 'X'.
APPEND I_BDCDATA.
CLEAR I_BDCDATA.
I_BDCDATA-FNAM = 'BDC_OKCODE'.
I_BDCDATA-FVAL = '=YES'.
APPEND I_BDCDATA.
CLEAR I_BDCDATA.
*---
CALL TRANSACTION 'XK01' USING I_BDCDATA
UPDATE 'A'
MODE 'E'.
REFRESH I_BDCDATA.
ENDLOOP.
2008 Apr 22 6:17 AM
&----
*& Report YBDC_UPLOAD_MM01_XLS *
*& *
&----
*& PURPOSE : MAKE CHANGES TO DOWNLOADED FILE AND UPLOAD THE FILE *
&----
REPORT YBDC_UPLOAD_MM01_XLS.
-
Tables
-
TABLES : mara. "General Material Data
-
Global BDCDATA Structure and MESSAGE Structure
-
DATA: gt_bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE,
gt_msgtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.
-
Global Variables
-
DATA: gv_infile TYPE string,
gv_msg TYPE string,
gv_update VALUE 'A'.
-
Internal Table
*----
DATA: BEGIN OF gt_data OCCURS 0,
matnr(20), "Material Number
mbrsh(20), "Account Group
mtart(20), "Material Type
meins(20), "Base Unit Of Measure
maktx(20), "Material Description
END OF gt_data.
-
Selection-screen
-
SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_file LIKE rlgrap-filename,
p_mode.
SELECTION-SCREEN : END OF BLOCK b1.
-
Select the File
-
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM fetch_file.
START-OF-SELECTION.
-
Fetch Data From XLS File
-
PERFORM fetch_data.
-
Fetch Data From XLS File
-
PERFORM delete_headerinfo.
-
Fetch Data From XLS File
-
PERFORM place_data.
&----
*& Form fetch_file
&----
text
-
--> p1 text
<-- p2 text
-
FORM fetch_file .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
FIELD_NAME = ' '
IMPORTING
file_name = p_file.
gv_infile = p_file.
ENDFORM. " fetch_file
&----
*& Form fetch_data
&----
text
-
--> p1 text
<-- p2 text
-
FORM fetch_data .
refresh : gt_data. "Clear Body Of the Internal Table
clear : gt_data. "Clear Header Line
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = gv_infile
filetype = 'ASC'
has_field_separator = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
data_tab = gt_data
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 ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
ENDFORM. " fetch_data
&----
*& Form place_data
&----
text
-
--> p1 text
<-- p2 text
-
FORM place_data .
LOOP AT gt_data.
PERFORM bdc_dynpro USING 'SAPLMGMM' '0060'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RMMG1-MATNR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=AUSW'.
PERFORM bdc_field USING 'RMMG1-MATNR'
gt_data-matnr.
PERFORM bdc_dynpro USING 'SAPLMGMM' '0070'.
PERFORM bdc_field USING 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
PERFORM bdc_field USING 'MSICHTAUSW-KZSEL(01)'
'X'.
PERFORM bdc_dynpro USING 'SAPLMGMM' '4004'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BU'.
PERFORM bdc_field USING 'BDC_CURSOR'
'MAKT-MAKTX'.
PERFORM bdc_field USING 'MAKT-MAKTX'
gt_data-maktx.
PERFORM bdc_field USING 'MARA-MTPOS_MARA'
'NORM'.
CALL TRANSACTION 'MM02' USING gt_bdcdata MODE p_mode
UPDATE gv_update
MESSAGES INTO gt_msgtab.
*For Error Messages Handling.
LOOP AT gt_msgtab.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = sy-msgid
lang = sy-langu
no = sy-msgno
v1 = sy-msgv1
v2 = sy-msgv2
v3 = sy-msgv3
v4 = sy-msgv4
IMPORTING
msg = gv_msg
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.
IF sy-tabix = 1.
WRITE: / 'Process Log' COLOR 3.
ENDIF.
WRITE:/ gv_msg.
ENDLOOP.
REFRESH gt_msgtab.
REFRESH gt_bdcdata.
ENDLOOP.
ENDFORM. " place_data
-
Start new screen *
-
FORM bdc_dynpro USING program dynpro.
CLEAR gt_bdcdata.
gt_bdcdata-program = program.
gt_bdcdata-dynpro = dynpro.
gt_bdcdata-dynbegin = 'X'.
APPEND gt_bdcdata.
ENDFORM. "BDC_DYNPRO
-
Insert field *
-
FORM bdc_field USING fnam fval.
CLEAR gt_bdcdata.
gt_bdcdata-fnam = fnam.
gt_bdcdata-fval = fval.
APPEND gt_bdcdata.
ENDFORM. "BDC_FIELD
&----
*& Form delete_headerinfo
&----
text
-
--> p1 text
<-- p2 text
-
FORM delete_headerinfo .
DELETE gt_data INDEX 1.
ENDFORM. " delete_headerinfo
-
FLAT FILE
-
*MATERIAL NUMBER INDUSTRY SECTOR MATERIAL TYPE BASE UNIT OF
*MEASURE MATERIAL DESCRIPTION
*806 M FERT CM IRON
*807 M HALB KG STEEL
*808 M HAWA KG IRON
-
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |