10-16-2008 6:11 AM
hi folks,
i have requirments in the transaction mb01 i need to upload the data using shdb with the transaction mb01 can anyone tell me the steps how exactly it works i have a general idea how the bdc works if anyone cud tell me the screen flows of the transaction n the sample code if they have used before that wud be quite helpful..
thanks n regards...
11-19-2008 7:25 AM
hello saba..
you have to do transaction recording using the t-code SHDB. enter the transaction mb01 in the transaction area and the start recording by entering all the fields or only the mandatory fields. then click on save..come back your transaction is saved and transform your transaction into program. converting it the program will look sum Wat like this..please see below. you have to create your own flat file with the structure same as it is found in recorder.
I'm sending the sample code, just copy and paste and see the result if some field is not working try changing value in that particular field..hope this will help other wise take it lite
****************************----
report ZMB01_RECPRO no standard page heading line-size 255.
include bdcrecx1.
parameters: dataset(132) lower case.
DO NOT CHANGE - the generated data section - DO NOT CHANGE ***
*
If it is nessesary to change the data section use the rules:
1.) Each definition of a field exists of two lines
2.) The first line shows exactly the comment
'* data element: ' followed with the data element
which describes the field.
If you don't have a data element use the
comment without a data element name
3.) The second line shows the fieldname of the
structure, the fieldname must consist of
a fieldname and optional the character '_' and
three numbers and the field length in brackets
4.) Each field must be type C.
*
Generated data section with specific formatting - DO NOT CHANGE ***
types: begin of record,
data element: BLDAT
BLDAT_001(010),
data element: BUDAT
BUDAT_002(010),
data element: LFSNR1
LFSNR_003(016),
data element: FRBNR1
FRBNR_004(016),
data element: BKTXT
BKTXT_005(025),
data element: XABLN
XABLN_006(010),
data element: BWARTWE
BWARTWE_007(003),
data element: BSTNR
EBELN_008(010),
data element: EBELP
EBELP_009(005),
data element: WERKS_D
WERKS_010(004),
data element: MB_GRBEW
GRUND_011(004),
data element: LGORT_D
LGORT_012(004),
data element:
XFULL_013(001),
data element: WVERS2
WVERS2_014(001),
data element: ERFMG
ERFMG_01_015(017),
end of record.
End generated data section ***
*-- create the internal table and the work area depending on above structure
data : it_tab type TABLE OF record,
wa_tab like LINE OF it_tab.
*-- start-of-selection
start-of-selection.
*-- calling the function module for uploadingthe data from the flat file to SAP sys.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'c:\Book1811.txt' "location of our flat file
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
VIRUS_SCAN_PROFILE =
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
HEADER =
tables
data_tab = it_tab
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.
*perform open_dataset using dataset.
*perform open_group.
loop at it_tab INTO wa_tab.
on change of wa_tab-EBELN_008.
*read dataset dataset into record.
*if sy-subrc <> 0. exit. endif.
*-- screen 200
perform bdc_dynpro using 'SAPMM07M' '0200'.
perform bdc_field using 'BDC_CURSOR'
'RM07M-LGORT'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MKPF-BLDAT'
wa_tab-BLDAT_001.
perform bdc_field using 'MKPF-BUDAT'
wa_tab-BUDAT_002.
perform bdc_field using 'RM07M-LFSNR'
wa_tab-LFSNR_003.
perform bdc_field using 'MKPF-FRBNR'
wa_tab-FRBNR_004.
perform bdc_field using 'MKPF-BKTXT'
wa_tab-BKTXT_005.
perform bdc_field using 'RM07M-XABLN'
wa_tab-XABLN_006.
*-- defaults for delivery items
perform bdc_field using 'RM07M-BWARTWE'
wa_tab-BWARTWE_007.
perform bdc_field using 'RM07M-EBELN'
wa_tab-EBELN_008.
perform bdc_field using 'RM07M-EBELP'
record-EBELP_009.
perform bdc_field using 'RM07M-WERKS'
wa_tab-WERKS_010.
perform bdc_field using 'RM07M-GRUND'
wa_tab-GRUND_011.
perform bdc_field using 'RM07M-LGORT'
wa_tab-LGORT_012.
perform bdc_field using 'XFULL'
record-XFULL_013.
perform bdc_field using 'RM07M-WVERS2'
record-WVERS2_014.
*-- screen 221
perform bdc_dynpro using 'SAPMM07M' '0221'.
perform bdc_field using 'BDC_CURSOR'
'MSEG-ERFMG(01)'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'MSEG-ERFMG(01)'
wa_tab-ERFMG_01_015.
perform bdc_transaction using 'MB01'.
refresh bdcdata[].
clear wa_tab.
endon.
endloop.
*perform close_group.
*perform close_dataset using dataset.
Regards,
sam_ar.