‎2006 Nov 21 8:10 AM
hi all:
I have got an error in my bdc program in processing sm35 ,but it didn't occur in transaction, my code is below:
data: l_opt TYPE ctu_params.
l_opt-dismode = CTUMODE.
l_opt-updmode = 'S'.
l_opt-nobinpt = 'X'.
batch input session
IF SESSION = 'X'.
CALL FUNCTION 'BDC_INSERT'
EXPORTING TCODE = TCODE
CTUPARAMS = l_opt
TABLES DYNPROTAB = BDCDATA.
IF SMALLLOG <> 'X'.
WRITE: / 'BDC_INSERT'(I03),
TCODE,
'returncode:'(I05),
SY-SUBRC,
'RECORD:',
SY-INDEX.
ENDIF.
call transaction using
ELSE.
call transaction using
REFRESH messtab.
CALL TRANSACTION TCODE USING BDCDATA
MODE CTUMODE
UPDATE CUPDATE
MESSAGES INTO MESSTAB.
CALL TRANSACTION tcode USING bdcdata
OPTIONS FROM l_opt
MESSAGES INTO messtab.
I got the error point . if l_opt-nobinpt = ' '. session mode and transaction mode are all error, but I can't find how to make session mode right.
I don't know how to show my picture ,sorry!
‎2006 Nov 21 8:32 AM
Please note that for creating a session, we need to open the session using FM: BDC_OPEN_GROUP, Insert the transacitons via: BDC_INSERT and lastly close the session via: BDC_CLOSE_GROUP.
Please check if you are following the same way.
Kind Regards
Eswar
‎2006 Nov 21 8:36 AM
‎2006 Nov 21 8:51 AM
Can you let us know the ERROR encountered. Is it while processing the session after creation in SM35 or within your program???
Also if possible please post the code to have a better feel and understanding.
Kind Regards
Eswar
‎2006 Nov 21 8:54 AM
report Z_MM_EXEC_BDC_MB1C_561
no standard page heading line-size 255.
include bdcrecx1.
*INCLUDE Z_MM_INCL_BDC_DATA_SSCR_FORM.
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 ***
data: begin of record occurs 0,
data element: BLDAT
BLDAT_001(010),
data element: BUDAT
BUDAT_002(010),
data element: BWARTWA
BWARTWA_003(003),
data element: WERKS_D
WERKS_004(004),
data element: LGORT_D
LGORT_005(004),
data element: WVERS3
WVERS3_006(001),
data element: MATNR
MATNR_01_007(018),
data element: ERFMG
ERFMG_01_008(017),
data element: ERFME
ERFME_01_009(003),
data element: CHARG_D
CHARG_01_010(010),
data element: ERFMG
ERFMG_011(017),
data element: EXBWR
EXBWR_012(016),
data element: MATNR
MATNR_013(018),
data element: ERFMG
ERFMG_014(017),
data element: ERFME
ERFME_015(003),
data element: WERKS_D
WERKS_016(004),
data element: LGORT_D
LGORT_017(004),
data element: CHARG_D
CHARG_018(010),
data element: EXBWR
EXBWR_019(016),
data element: MATNR
MATNR_020(018),
data element: ERFMG
ERFMG_021(017),
data element: ERFME
ERFME_022(003),
data element: WERKS_D
WERKS_023(004),
data element: LGORT_D
LGORT_024(004),
data element: CHARG_D
CHARG_025(010),
data element: EXBWR
EXBWR_026(016),
end of record.
data: record_n like record occurs 0 with header line.
End generated data section ***
start-of-selection.
CALL FUNCTION 'UPLOAD'
EXPORTING
BIN_FILESIZE = ' '
CODEPAGE = ' '
FILENAME = 'D:\BOOK1.TXT '
FILETYPE = 'DAT'
MODE = ' '
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
COL_SELECT = ' '
COL_SELECTMASK = ' '
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = RECORD
FIELDNAMES =
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
INVALID_FILESIZE = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
NO_AUTHORITY = 10
OTHERS = 11
.
*perform open_dataset using dataset.
perform open_group.
append lines of RECORD to record_n.
*do.
*
*read dataset dataset into record.
*if sy-subrc <> 0. exit. endif.
LOOP AT RECORD FROM 2.
data: tabix like sy-tabix.
clear tabix.
tabix = sy-tabix + 1.
if record-WERKS_004 is not initial.
if sy-tabix <> '2'.
perform bdc_transaction using 'MB1C'.
endif.
perform bdc_dynpro using 'SAPMM07M' '0400'.
*perform bdc_field using 'BDC_CURSOR'
'RM07M-BWARTWA'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MKPF-BLDAT'
sy-datum.
perform bdc_field using 'MKPF-BUDAT'
sy-datum.
perform bdc_field using 'RM07M-BWARTWA'
'561'.
perform bdc_field using 'RM07M-WERKS'
record-WERKS_004.
perform bdc_field using 'RM07M-LGORT'
record-LGORT_005.
perform bdc_field using 'RM07M-WVERS3'
'X'.
perform bdc_dynpro using 'SAPMM07M' '0421'.
perform bdc_field using 'BDC_CURSOR'
'MSEG-ERFMG(01)'.
perform bdc_field using 'BDC_OKCODE'
'=PF02'.
perform bdc_field using 'MSEG-MATNR(01)'
record-MATNR_01_007.
perform bdc_field using 'MSEG-ERFMG(01)'
record-ERFMG_01_008.
perform bdc_field using 'MSEG-ERFME(01)'
record-ERFME_01_009.
perform bdc_field using 'MSEG-CHARG(01)'
record-CHARG_01_010.
perform bdc_dynpro using 'SAPMM07M' '0410'.
perform bdc_field using 'BDC_CURSOR'
'MSEG-EXBWR'.
*=新行,可能直接点保存
read table record_n index tabix. "判断下一行是否为新行
data: l_subrc like sy-subrc.
l_subrc = sy-subrc.
if record_n-WERKS_004 is not initial or l_subrc <> 0.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
else.
perform bdc_field using 'BDC_OKCODE'
'=NPE'.
endif.
*perform bdc_field using 'MSEG-ERFMG'
record-ERFMG_011.
perform bdc_field using 'MSEG-EXBWR'
record-EXBWR_012.
else.
perform bdc_dynpro using 'SAPMM07M' '0410'.
perform bdc_field using 'BDC_CURSOR'
'MSEG-EXBWR'.
read table record_n index tabix. "判断下一行是否为新行
l_subrc = sy-subrc.
if record_n-WERKS_004 is not initial or l_subrc <> 0.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
else.
perform bdc_field using 'BDC_OKCODE'
'NPE'.
endif.
perform bdc_field using 'MSEG-MATNR'
record-MATNR_01_007.
perform bdc_field using 'MSEG-ERFMG'
record-ERFMG_01_008.
perform bdc_field using 'MSEG-ERFME'
record-ERFME_01_009.
*perform bdc_field using 'MSEG-WERKS'
record-WERKS_016.
*perform bdc_field using 'MSEG-LGORT'
record-LGORT_017.
perform bdc_field using 'MSEG-CHARG'
record-CHARG_01_010.
perform bdc_field using 'MSEG-EXBWR'
record-EXBWR_012.
*perform bdc_dynpro using 'SAPMM07M' '0410'.
*perform bdc_field using 'BDC_CURSOR'
'MSEG-EXBWR'.
*perform bdc_field using 'BDC_OKCODE'
'=BU'.
*perform bdc_field using 'MSEG-MATNR'
record-MATNR_020.
*perform bdc_field using 'MSEG-ERFMG'
record-ERFMG_021.
*perform bdc_field using 'MSEG-ERFME'
record-ERFME_022.
*perform bdc_field using 'MSEG-WERKS'
record-WERKS_023.
*perform bdc_field using 'MSEG-LGORT'
record-LGORT_024.
*perform bdc_field using 'MSEG-CHARG'
record-CHARG_025.
*perform bdc_field using 'MSEG-EXBWR'
record-EXBWR_026.
endif.
endloop.
perform bdc_transaction using 'MB1C'.
*enddo.
perform close_group.
*perform close_dataset using dataset.
‎2006 Nov 21 9:49 AM
Hi Liang
Please check with this code:
INCLUDE BDCRECX1.
*INCLUDE Z_MM_INCL_BDC_DATA_SSCR_FORM.
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 ***
DATA: BEGIN OF RECORD OCCURS 0,
* data element: BLDAT
* BLDAT_001(010),
** data element: BUDAT
* BUDAT_002(010),
* data element: BWARTWA
* BWARTWA_003(003),
* data element: WERKS_D
WERKS_004(004),
* data element: LGORT_D
LGORT_005(004),
* data element: WVERS3
* WVERS3_006(001),
* data element: MATNR
MATNR_01_007(018),
* data element: ERFMG
ERFMG_01_008(017),
* data element: ERFME
ERFME_01_009(003),
* data element: CHARG_D
CHARG_01_010(010),
* data element: ERFMG
* ERFMG_011(017),
* data element: EXBWR
EXBWR_012(016),
* data element: MATNR
* MATNR_013(018),
* data element: ERFMG
* ERFMG_014(017),
** data element: ERFME
* ERFME_015(003),
** data element: WERKS_D
* WERKS_016(004),
** data element: LGORT_D
* LGORT_017(004),
** data element: CHARG_D
* CHARG_018(010),
** data element: EXBWR
* EXBWR_019(016),
* data element: MATNR
MATNR_020(018),
* data element: ERFMG
ERFMG_021(017),
* data element: ERFME
ERFME_022(003),
* data element: WERKS_D
WERKS_023(004),
* data element: LGORT_D
LGORT_024(004),
* data element: CHARG_D
CHARG_025(010),
* data element: EXBWR
EXBWR_026(016),
END OF RECORD.
DATA: RECORD_N LIKE RECORD OCCURS 0 WITH HEADER LINE.
*** End generated data section ***
START-OF-SELECTION.
CALL FUNCTION 'UPLOAD'
EXPORTING
* BIN_FILESIZE = ' '
* CODEPAGE = ' '
FILENAME = 'D:BOOK1.TXT '
FILETYPE = 'DAT'
* MODE = ' '
* WK1_N_FORMAT = ' '
* WK1_N_SIZE = ' '
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
* COL_SELECT = ' '
* COL_SELECTMASK = ' '
* NO_AUTH_CHECK = ' '
* IMPORTING
* FILELENGTH =
TABLES
DATA_TAB = RECORD
* FIELDNAMES =
* EXCEPTIONS
* FILE_OPEN_ERROR = 1
* FILE_WRITE_ERROR = 2
* INVALID_FILESIZE = 3
* INVALID_TYPE = 4
* NO_BATCH = 5
* UNKNOWN_ERROR = 6
* INVALID_TABLE_WIDTH = 7
* GUI_REFUSE_FILETRANSFER = 8
* CUSTOMER_ERROR = 9
* NO_AUTHORITY = 10
* OTHERS = 11
.
*perform open_dataset using dataset.
PERFORM OPEN_GROUP.
APPEND LINES OF RECORD TO RECORD_N.
*do.
*
*read dataset dataset into record.
*if sy-subrc <> 0. exit. endif.
LOOP AT RECORD FROM 2.
DATA: TABIX LIKE SY-TABIX.
CLEAR TABIX.
TABIX = SY-TABIX + 1.
IF RECORD-WERKS_004 IS NOT INITIAL.
PERFORM BDC_DYNPRO USING 'SAPMM07M' '0400'.
*perform bdc_field using 'BDC_CURSOR'
* 'RM07M-BWARTWA'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'MKPF-BLDAT'
SY-DATUM.
PERFORM BDC_FIELD USING 'MKPF-BUDAT'
SY-DATUM.
PERFORM BDC_FIELD USING 'RM07M-BWARTWA'
'561'.
PERFORM BDC_FIELD USING 'RM07M-WERKS'
RECORD-WERKS_004.
PERFORM BDC_FIELD USING 'RM07M-LGORT'
RECORD-LGORT_005.
PERFORM BDC_FIELD USING 'RM07M-WVERS3'
'X'.
PERFORM BDC_DYNPRO USING 'SAPMM07M' '0421'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'MSEG-ERFMG(01)'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=PF02'.
PERFORM BDC_FIELD USING 'MSEG-MATNR(01)'
RECORD-MATNR_01_007.
PERFORM BDC_FIELD USING 'MSEG-ERFMG(01)'
RECORD-ERFMG_01_008.
PERFORM BDC_FIELD USING 'MSEG-ERFME(01)'
RECORD-ERFME_01_009.
PERFORM BDC_FIELD USING 'MSEG-CHARG(01)'
RECORD-CHARG_01_010.
PERFORM BDC_DYNPRO USING 'SAPMM07M' '0410'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'MSEG-EXBWR'.
*=新行,可能直接点保存
READ TABLE RECORD_N INDEX TABIX. "判断下一行是否为新行
DATA: L_SUBRC LIKE SY-SUBRC.
L_SUBRC = SY-SUBRC.
IF RECORD_N-WERKS_004 IS NOT INITIAL OR L_SUBRC <> 0.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=BU'.
ELSE.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=NPE'.
ENDIF.
*perform bdc_field using 'MSEG-ERFMG'
* record-ERFMG_011.
PERFORM BDC_FIELD USING 'MSEG-EXBWR'
RECORD-EXBWR_012.
ELSE.
PERFORM BDC_DYNPRO USING 'SAPMM07M' '0410'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'MSEG-EXBWR'.
READ TABLE RECORD_N INDEX TABIX. "判断下一行是否为新行
L_SUBRC = SY-SUBRC.
IF RECORD_N-WERKS_004 IS NOT INITIAL OR L_SUBRC <> 0.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=BU'.
ELSE.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'NPE'.
ENDIF.
PERFORM BDC_FIELD USING 'MSEG-MATNR'
RECORD-MATNR_01_007.
PERFORM BDC_FIELD USING 'MSEG-ERFMG'
RECORD-ERFMG_01_008.
PERFORM BDC_FIELD USING 'MSEG-ERFME'
RECORD-ERFME_01_009.
*perform bdc_field using 'MSEG-WERKS'
* record-WERKS_016.
*perform bdc_field using 'MSEG-LGORT'
* record-LGORT_017.
PERFORM BDC_FIELD USING 'MSEG-CHARG'
RECORD-CHARG_01_010.
PERFORM BDC_FIELD USING 'MSEG-EXBWR'
RECORD-EXBWR_012.
*perform bdc_dynpro using 'SAPMM07M' '0410'.
*perform bdc_field using 'BDC_CURSOR'
* 'MSEG-EXBWR'.
*perform bdc_field using 'BDC_OKCODE'
* '=BU'.
*perform bdc_field using 'MSEG-MATNR'
* record-MATNR_020.
*perform bdc_field using 'MSEG-ERFMG'
* record-ERFMG_021.
*perform bdc_field using 'MSEG-ERFME'
* record-ERFME_022.
*perform bdc_field using 'MSEG-WERKS'
* record-WERKS_023.
*perform bdc_field using 'MSEG-LGORT'
* record-LGORT_024.
*perform bdc_field using 'MSEG-CHARG'
* record-CHARG_025.
*perform bdc_field using 'MSEG-EXBWR'
* record-EXBWR_026.
ENDIF.
PERFORM BDC_TRANSACTION USING 'MB1C'.
ENDLOOP.
*enddo.
PERFORM CLOSE_GROUP.
*perform close_dataset using dataset.If you are still encountering the problem, kindly let us know the error description...
Kind Regards
Eswar
‎2006 Nov 21 9:59 AM
Hi,
can you give us the details or the error description.
santhosh
‎2006 Nov 21 10:06 AM
the error is when i process the session using this 'MB1C' BDC, another screen pop up unexpectly. It's unlike what I am seeing when I process MB1C directly.
I KNOW is a 'batch input session' , but in 'SHDB', I already click the checkbox 'not a batch input cession' .AND in my program , I give the value 'l_opt-nobinpt = 'X'.'.
thanks for all your help! ^^
‎2006 Nov 21 10:15 AM
Hi Liang
I would advice you to use: <b>BAPI_GOODSMVT_CREATE</b> for handling the same.
Documentation of the BAPI can help you using the same.
Kind Regards
Eswar
‎2006 Nov 21 10:32 AM