Bdc table control.
Dear forums friends,
i have a problem in bdc table control.I send my report below,
please check it and tell me what is the problem,why this report not excute.
please tell me quickly.
regard
Rasmi.
REPORT ztable_control
NO STANDARD PAGE HEADING LINE-SIZE 255.
*include bdcrecx1.
*start-of-selection.
*perform open_group.
DATA: it_exload LIKE alsmex_tabline OCCURS 0 WITH HEADER LINE.
DATA : str1 TYPE string,
var1(2) TYPE n.
var1 = 0.
DATA: BEGIN OF itab OCCURS 0,
cldte(8) TYPE n,
ocrsn(4) TYPE n,
END OF itab.
DATA: var3 TYPE dats,
var6 TYPE integer.
itab-cldte = var3.
itab2-cldte = var3.
itab-ocrsn = var6.
itab2-ocrsn = var6.
DATA: BEGIN OF itab1 OCCURS 0,
cldte(8) TYPE n,
ocrsn(4) TYPE n,
pernr(1) TYPE n,
taxcd LIKE pinct-taxcd,
betrg(1) TYPE n,
voudt(10) TYPE c,
vouam(2) TYPE n,
END OF itab1.
DATA var(1) TYPE c.
DATA: bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
PARAMETER: file_fi LIKE rlgrap-filename OBLIGATORY,
w_begin TYPE i OBLIGATORY,
w_end TYPE i OBLIGATORY,
rad1 RADIOBUTTON GROUP gp1,
rad2 RADIOBUTTON GROUP gp1 DEFAULT 'X',
rad3 RADIOBUTTON GROUP gp1 .
AT SELECTION-SCREEN ON VALUE-REQUEST FOR file_fi.
PERFORM sub_browse_file.
START-OF-SELECTION *
START-OF-SELECTION.
PERFORM mode_selection.
PERFORM sub_data_load.
PERFORM sub_data_transform.
PERFORM sub_post_data.
BROWS FILE *
FORM sub_browse_file .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = ' '
IMPORTING
file_name = file_fi.
ENDFORM. "sub_browse_file
DATA LOAD *
FORM sub_data_load.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = file_fi
i_begin_col = '0001'
i_begin_row = w_begin
i_end_col = '0007'
i_end_row = w_end
TABLES
intern = it_exload.
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_data_load
DATA TRANSFORM *
FORM sub_data_transform .
LOOP AT it_exload.
CASE it_exload-col.
WHEN '0001'.
itab-cldte = it_exload-value.
itab1-cldte = it_exload-value.
WHEN '0002'.
itab-ocrsn = it_exload-value.
itab1-ocrsn = it_exload-value.
WHEN '0003'.
itab1-pernr = it_exload-value.
WHEN '0004'.
itab1-taxcd = it_exload-value.
WHEN '0005'.
itab1-betrg = it_exload-value.
WHEN '0006'.
itab1-voudt = it_exload-value.
WHEN '0007'.
itab1-vouam = it_exload-value.
ENDCASE.
AT END OF row.
APPEND itab.
CLEAR itab.
APPEND itab1.
CLEAR itab1.
IF itab-cldte = ' '.
itab1-cldte = ' '.
itab-ocrsn = ' '.
itab1-ocrsn = ' '.
WRITE : / var3.
WRITE : / var6.
ENDIF.
ENDAT.
ENDLOOP.
*SORT itab by cldte.
*delete ADJACENT DUPLICATES FROM itab2.
ENDFORM. "sub_data_transform
Form sub_post_data *
FORM sub_post_data .
LOOP AT itab.
PERFORM bdc_dynpro USING 'HINCREMP' '3000'.
PERFORM bdc_field USING 'BDC_CURSOR'
'WA_CLAIMS-VOUAM(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=PROC'.
PERFORM bdc_field USING 'RPCCLMIN-CLDTE'
itab-cldte . "'01.02.2009'.
PERFORM bdc_field USING 'RPCCLMIN-OCRSN'
itab-ocrsn. " '0002'.
LOOP AT itab1 WHERE cldte = itab1-cldte AND ocrsn = itab-ocrsn.
CONCATENATE 'wa_claims-pernr(' var1 ')' INTO str1.
PERFORM bdc_field USING str1
itab1-pernr. "'001'
CONCATENATE 'WA_CLAIMS-TAXCD (' var1')' INTO str1.
PERFORM bdc_field USING str1
itab1-taxcd. "'SCHA'.
CONCATENATE 'WA_CLAIMS-BETRG(' var1')' INTO str1.
PERFORM bdc_field USING str1
itab1-betrg. "'1'.
CONCATENATE 'WA_CLAIMS-VOUDT(' var1 ')' INTO str1.
PERFORM bdc_field USING str1
itab1-voudt. "'02.02.2009'.
CONCATENATE 'WA_CLAIMS-VOUAM(' var1')' INTO str1.
PERFORM bdc_field USING str1
itab1-vouam. "'50'.
var1 = var1 + 1.
Endif.
ENDLOOP. "'50'.
PERFORM bdc_dynpro USING 'HINCREMP' '4000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BACK'.
PERFORM bdc_dynpro USING 'HINCREMP' '3000'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RPCCLMIN-CLDTE'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BACK'.
PERFORM bdc_field USING 'RPCCLMIN-CLDTE'
'01.02.2009'.
PERFORM bdc_field USING 'RPCCLMIN-OCRSN'
'0002'.
PERFORM bdc_dynpro USING 'SAPLSPO1' '0100'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=YES'.
*perform bdc_transaction using 'PC00_M40_REMP'.
CALL TRANSACTION 'PC00_M40_REMP' USING bdcdata MESSAGES INTO messtab MODE var.
"UPDATE 'S'
"MODE var.
Endloop.
Endform.
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 FILE *
FORM bdc_field USING fnam fval.
IF fval <> space.
CLEAR bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
APPEND bdcdata.
ENDIF.
ENDFORM. "BDC_FIELD
MODE-SELECTION *
FORM mode_selection .
IF rad1 = 'X'.
var = 'P'.
ELSEIF rad2 = 'X'.
var = 'E'.
ELSEIF rad3 = 'X'.
var = 'A'.
ENDIF.
ENDFORM. " mode_selecti
Hi,
Check this ...
REPORT ztable_control
NO STANDARD PAGE HEADING LINE-SIZE 255.
*include bdcrecx1.
*start-of-selection.
*perform open_group.
DATA: it_exload LIKE alsmex_tabline OCCURS 0 WITH HEADER LINE.
DATA : str1 TYPE string,
var1(2) TYPE n.
var1 = 1. " Change here and check
DATA: BEGIN OF itab OCCURS 0,
cldte(8) TYPE n,
ocrsn(4) TYPE n,
END OF itab.
DATA: var3 TYPE dats,
var6 TYPE integer.
itab-cldte = var3.
itab2-cldte = var3.
itab-ocrsn = var6.
itab2-ocrsn = var6.
DATA: BEGIN OF itab1 OCCURS 0,
cldte(8) TYPE n,
ocrsn(4) TYPE n,
pernr(1) TYPE n,
taxcd LIKE pinct-taxcd,
betrg(1) TYPE n,
voudt(10) TYPE c,
vouam(2) TYPE n,
END OF itab1.
DATA var(1) TYPE c.
DATA: bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
PARAMETER: file_fi LIKE rlgrap-filename OBLIGATORY,
w_begin TYPE i OBLIGATORY,
w_end TYPE i OBLIGATORY,
rad1 RADIOBUTTON GROUP gp1,
rad2 RADIOBUTTON GROUP gp1 DEFAULT 'X',
rad3 RADIOBUTTON GROUP gp1 .
AT SELECTION-SCREEN ON VALUE-REQUEST FOR file_fi.
PERFORM sub_browse_file.
START-OF-SELECTION *
START-OF-SELECTION.
PERFORM mode_selection.
PERFORM sub_data_load.
PERFORM sub_data_transform.
PERFORM sub_post_data.
BROWS FILE *
FORM sub_browse_file .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = ' '
IMPORTING
file_name = file_fi.
ENDFORM. "sub_browse_file
DATA LOAD *
FORM sub_data_load.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = file_fi
i_begin_col = '0001'
i_begin_row = w_begin
i_end_col = '0007'
i_end_row = w_end
TABLES
intern = it_exload.
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_data_load
DATA TRANSFORM *
FORM sub_data_transform .
LOOP AT it_exload.
CASE it_exload-col.
WHEN '0001'.
itab-cldte = it_exload-value.
itab1-cldte = it_exload-value.
WHEN '0002'.
itab-ocrsn = it_exload-value.
itab1-ocrsn = it_exload-value.
WHEN '0003'.
itab1-pernr = it_exload-value.
WHEN '0004'.
itab1-taxcd = it_exload-value.
WHEN '0005'.
itab1-betrg = it_exload-value.
WHEN '0006'.
itab1-voudt = it_exload-value.
WHEN '0007'.
itab1-vouam = it_exload-value.
ENDCASE.
AT END OF row.
APPEND itab.
CLEAR itab.
APPEND itab1.
CLEAR itab1.
IF itab-cldte = ' '.
itab1-cldte = ' '.
itab-ocrsn = ' '.
itab1-ocrsn = ' '.
WRITE : / var3.
WRITE : / var6.
ENDIF.
ENDAT.
ENDLOOP.
*SORT itab by cldte.
*delete ADJACENT DUPLICATES FROM itab2.
ENDFORM. "sub_data_transform
Form sub_post_data *
FORM sub_post_data .
LOOP AT itab.
PERFORM bdc_dynpro USING 'HINCREMP' '3000'.
PERFORM bdc_field USING 'BDC_CURSOR'
'WA_CLAIMS-VOUAM(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=PROC'.
PERFORM bdc_field USING 'RPCCLMIN-CLDTE'
itab-cldte . "'01.02.2009'.
PERFORM bdc_field USING 'RPCCLMIN-OCRSN'
itab-ocrsn. " '0002'.
LOOP AT itab1 WHERE cldte = itab1-cldte AND ocrsn = itab-ocrsn.
CONCATENATE 'wa_claims-pernr(' var1 ')' INTO str1.
PERFORM bdc_field USING str1
itab1-pernr. "'001'
CONCATENATE 'WA_CLAIMS-TAXCD (' var1')' INTO str1.
PERFORM bdc_field USING str1
itab1-taxcd. "'SCHA'.
CONCATENATE 'WA_CLAIMS-BETRG(' var1')' INTO str1.
PERFORM bdc_field USING str1
itab1-betrg. "'1'.
CONCATENATE 'WA_CLAIMS-VOUDT(' var1 ')' INTO str1.
PERFORM bdc_field USING str1
itab1-voudt. "'02.02.2009'.
CONCATENATE 'WA_CLAIMS-VOUAM(' var1')' INTO str1.
PERFORM bdc_field USING str1
itab1-vouam. "'50'.
var1 = var1 + 1.
Endif.
ENDLOOP. "'50'.
PERFORM bdc_dynpro USING 'HINCREMP' '4000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BACK'.
PERFORM bdc_dynpro USING 'HINCREMP' '3000'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RPCCLMIN-CLDTE'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BACK'.
PERFORM bdc_field USING 'RPCCLMIN-CLDTE'
'01.02.2009'.
PERFORM bdc_field USING 'RPCCLMIN-OCRSN'
'0002'.
PERFORM bdc_dynpro USING 'SAPLSPO1' '0100'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=YES'.
*perform bdc_transaction using 'PC00_M40_REMP'.
CALL TRANSACTION 'PC00_M40_REMP' USING bdcdata MESSAGES INTO messtab MODE var.
"UPDATE 'S'
"MODE var.
Endloop.
Endform.
Similar Messages
-
BDC table control using Excel sheet upload
Hi All,
I am working BDC table control.I want to upload the From excel sheet.I am using the FM ALSM_EXCEL_TO_INTERNAL_TABLE to upload the the data into my internal table.The data is populating in the internal table.
Now i have problem tat how to populate this excel sheet data to the Bdc table control.
Can nybody help me out.\[removed by moderator\]
Thanks,
Swapna.
Edited by: Jan Stallkamp on Jul 25, 2008 10:57 AMafter fetching data from EXCEL sheet, each column data (in excel sheet) will be uploaded to individual record into your internal table along with row number and column number, loop through that internal table and collect all your excel data into record format.pls refer the below code.
data:
i_excel type alsmex_tabline occurs 0 with header line,
l_row type i value 1.
data:
begin of x_data occurs 0,
kunnr like RF02L-KUNNR,
klimk(17) type c,
CTLPC like knkk-CTLPC,
end of x_data,
begin of x_data1 occurs 0,
data(106),
end of x_data1.
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = p_fname
i_begin_col = 1
i_begin_row = 1
i_end_col = no.of columns in your excel file
i_end_row = no.of rows in your file
tables
intern = i_excel.
if sy-subrc = 0.
loop at i_excel.
if l_row <> i_excel-row.
append x_data.
clear x_data.
endif.
case i_excel-col.
when 1.
x_data-kunnr = i_excel-value.
when 2.
x_data-klimk = i_excel-value.
when 3.
x_data-CTLPC = i_excel-value.
endcase.
l_row = i_excel-row.
clear i_excel.
at last.
append x_data.
endat.
endloop.
endif.
then loop through the internal table X_DATA, pass the data to your table control like.
tbl_control-field1(1) = x_data-field1.
tbl_control-field2(1) = x_data-field2.
tbl_control-fieldn(1) = x_data-fieldn.
Regards,
Sreeram. -
How to create screen resolution in bdc table control
hi gurus
can anyone suggest me
how to create screen resolution in bdc table control
thanks®ards
mark.Hi ,
Using CTU_PARAMS table for screen resolution .
For this sample code.
This is for Transation FB60.
report ZZFB60
no standard page heading line-size 255.
tables t100.
PARAMETERS : p_file1 like rlgrap-filename,
p_doctyp like RF05A-BUSCS,
p_invdat like INVFO-BLDAT,
p_posdat like INVFO-BUDAT.
CONSTANTS : C_TRANS_FB60(4) VALUE 'FB60'.
*Parameter string for runtime of CALL TRANSACTION
data : l_option type ctu_params,
l_subrc type sysubrc.
DATA : l_mstring(150).
data accnt type char17.
data : day type char2,
month type char2,
year type char4,
date1 type char10,
date2 type char10.
data : cnt(2) TYPE n,
cnt1 type i,
fld(25) TYPE c.
data : begin of excel occurs 0,
fieldname(255) type c,
end of excel.
DATA:BEGIN OF it_mess OCCURS 0,
msgtyp(5),
lms(200),
msgv1(50),
END OF it_mess.
data: begin of t_record occurs 0,
BUKRS(004),
ACCNT(017),
XBLNR(016),
WRBTR1(016),
WAERS(005),
SECCO(004) ,
SGTXT(050),
HKONT(010),
WRBTR2(017),
MWSKZ(002),
GSBER(004),
KOSTL(010),
end of t_record.
*Internal Table for Header Data
DATA : BEGIN OF t_head OCCURS 0,
BUKRS(004), "Company Code
ACCNT(017), "Account or Vendor
XBLNR(016), "Reference
WRBTR1(017), "Amount in document currency
WAERS(005), "Currency
SECCO(004), "Section Code
SGTXT(050), "Text
END OF t_head.
*Internal table for Item Data
DATA : BEGIN OF t_item OCCURS 0,
ACCNT(017), "Account
HKONT(010), "GL Account
WRBTR2(017), "Line item Amount in document currency
MWSKZ(002), "Tax Code
GSBER(004), " Business Area
KOSTL(010), "Cost centre
END OF t_item.
DATA: IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE,
IT_BDC_MESSAGES LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
*include bdcrecx1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file1.
PERFORM file_selection.
PERFORM data_upload.
PERFORM table_control.
start-of-selection.
l_option-defsize = 'X'.
l_option-dismode = 'A'.
l_option-updmode = 'S'.
day = p_invdat+6(2).
month = p_invdat+4(2).
year = p_invdat+0(4).
concatenate day month year into date1 SEPARATED BY '.'.
day = p_posdat+6(2).
month = p_posdat+4(2).
year = p_posdat+0(4).
concatenate day month year into date2 SEPARATED BY '.'.
*perform open_group.
loop at t_head.
CLEAR IT_BDCDATA.
REFRESH IT_BDCDATA.
perform bdc_dynpro using 'SAPLACHD' '1000'.
perform bdc_field using 'BDC_OKCODE' '=ENTR'.
perform bdc_field using 'BKPF-BUKRS' t_head-bukrs.
perform bdc_dynpro using 'SAPMF05A' '1100'.
perform bdc_field using 'BDC_OKCODE' '/00'.
perform bdc_field using 'RF05A-BUSCS' p_doctyp.
perform bdc_field using 'INVFO-ACCNT' t_head-accnt.
perform bdc_field using 'INVFO-BLDAT' date1.
perform bdc_field using 'INVFO-BUDAT' date2.
perform bdc_field using 'INVFO-XBLNR' t_head-xblnr.
perform bdc_field using 'INVFO-WRBTR' t_head-wrbtr1.
perform bdc_field using 'INVFO-WAERS' t_head-waers.
perform bdc_field using 'INVFO-SECCO' t_head-secco.
perform bdc_field using 'INVFO-SGTXT' t_head-sgtxt.
cnt = 1.
cnt1 = 1.
loop at t_item where accnt = t_head-accnt.
*if cnt > 4.
*cnt = 4.
*endif.
if cnt1 gt 1.
CONCATENATE 'ACGL_ITEM-MARKSP(' cnt ')' INTO fld.
perform bdc_field using fld 'X'.
perform bdc_dynpro using 'SAPMF05A' '1100'.
perform bdc_field using 'BDC_OKCODE' '=0005'.
endif.
perform bdc_dynpro using 'SAPMF05A' '1100'.
perform bdc_field using 'BDC_OKCODE' '/00'.
CONCATENATE 'ACGL_ITEM-HKONT(' cnt ')' INTO fld.
perform bdc_field using fld t_item-hkont.
CONCATENATE 'ACGL_ITEM-WRBTR(' cnt ')' INTO fld.
perform bdc_field using fld t_item-wrbtr2.
CONCATENATE 'ACGL_ITEM-MWSKZ(' cnt ')' INTO fld.
perform bdc_field using fld t_item-mwskz.
CONCATENATE 'ACGL_ITEM-GSBER(' cnt ')' INTO fld.
perform bdc_field using fld t_item-gsber.
CONCATENATE 'ACGL_ITEM-KOSTL(' cnt ')' INTO fld.
perform bdc_field using fld t_item-kostl.
perform bdc_field using 'BDC_CURSOR' fld.
*CONCATENATE 'ACGL_ITEM-MARKSP(' cnt ')' INTO fld.
*perform bdc_field using fld 'X'.
cnt1 = cnt1 + 1.
*cnt = cnt + 1.
*if cnt > 1.
*perform bdc_dynpro using 'SAPMF05A' '1100'.
*perform bdc_field using 'BDC_OKCODE' '=0005'.
**perform bdc_field using 'BDC_OKCODE' '=0006'.
*endif.
endloop.
perform bdc_dynpro using 'SAPMF05A' '1100'.
perform bdc_field using 'BDC_OKCODE'
'=BS'.
perform bdc_dynpro using 'SAPMSSY0' '0120'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
*perform bdc_transaction using 'FB60'.
CALL TRANSACTION C_TRANS_FB60 USING IT_BDCDATA options from l_option
MESSAGES INTO IT_BDC_MESSAGES.
perform error.
perform errordownload.
endloop.
*perform close_group.
*Form data_upload
FORM data_upload .
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = p_file1
FILETYPE = 'DAT'
TABLES
DATA_TAB = t_record.
ENDFORM. " data_upload
*Form file_selection
FORM file_selection .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = 'p_file1'
IMPORTING
file_name = p_file1.
ENDFORM. " file_selection
Form BDC_DYNPRO
FORM BDC_DYNPRO using program dynpro.
CLEAR IT_BDCDATA.
IT_BDCDATA-PROGRAM = PROGRAM.
IT_BDCDATA-DYNPRO = DYNPRO.
IT_BDCDATA-DYNBEGIN = 'X'.
APPEND IT_BDCDATA.
endform.
*Form BDC_FIELD
FORM bdc_field using fnam fval.
CLEAR IT_BDCDATA.
IT_BDCDATA-FNAM = FNAM.
IT_BDCDATA-FVAL = FVAL.
APPEND IT_BDCDATA.
ENDFORM.
Table Control
FORM table_control .
LOOP AT t_record.
ON CHANGE OF t_record-accnt.
MOVE-CORRESPONDING t_record TO t_head.
APPEND t_head.
ENDON.
loop at t_head.
t_item-accnt = t_head-accnt.
t_item-hkont = t_record-hkont.
t_item-wrbtr2 = t_record-wrbtr2 .
t_item-mwskz = t_record-mwskz .
t_item-gsber = t_record-gsber .
t_item-kostl = t_record-kostl.
APPEND t_item.
endloop.
If t_record-level = 'H'.
t_head-bukrs = t_record-text1.
t_head-accnt = t_record-text2.
t_head-xblnr = t_record-text3.
t_head-wrbtr1 = t_record-text4.
t_head-waers = t_record-text5.
t_head-secco = t_record-text6.
t_head-sgtxt = t_record-text7.
APPEND t_head.
else.
t_item-accnt = t_head-accnt.
t_item-hkont = t_record-text1.
t_item-wrbtr2 = t_record-text2.
t_item-mwskz = t_record-text3.
t_item-gsber = t_record-text4.
t_item-kostl = t_record-text5.
APPEND t_item.
endif.
ENDLOOP.
ENDFORM.
FORM error .
LOOP AT IT_BDC_MESSAGES.
IF IT_BDC_MESSAGES-msgtyp = 'E'.
SELECT single * FROM t100 WHERE
sprsl = it_BDC_MESSAGES-msgspra
AND arbgb = IT_BDC_MESSAGES-msgid
AND msgnr = IT_BDC_MESSAGES-msgnr.
IF sy-subrc = 0.
l_mstring = t100-text.
IF l_mstring CS '&1'.
REPLACE '&1' WITH IT_BDC_MESSAGES-msgv1 INTO l_mstring.
REPLACE '&2' WITH IT_BDC_MESSAGES-msgv2 INTO l_mstring.
REPLACE '&3' WITH IT_BDC_MESSAGES-msgv3 INTO l_mstring.
REPLACE '&4' WITH IT_BDC_MESSAGES-msgv4 INTO l_mstring.
ELSE.
REPLACE '&' WITH IT_BDC_MESSAGES-msgv1 INTO l_mstring.
REPLACE '&' WITH IT_BDC_MESSAGES-msgv2 INTO l_mstring.
REPLACE '&' WITH IT_BDC_MESSAGES-msgv3 INTO l_mstring.
REPLACE '&' WITH IT_BDC_MESSAGES-msgv4 INTO l_mstring.
ENDIF.
CONDENSE l_mstring.
it_mess-msgtyp = IT_BDC_MESSAGES-msgtyp.
it_mess-lms = l_mstring.
it_mess-msgv1 = IT_BDC_MESSAGES-msgv1.
APPEND it_mess.
ELSE.
it_mess-msgtyp = IT_BDC_MESSAGES-msgtyp.
it_mess-lms = l_mstring.
it_mess-msgv1 = IT_BDC_MESSAGES-msgv1.
APPEND it_mess.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM.
form errordownload.
*down the internal table to excel file.
call function 'EXCEL_OLE_STANDARD_DAT'
EXPORTING
file_name = 'c:/Error.xls'
TABLES
data_tab = it_mess
fieldnames = excel
EXCEPTIONS
file_not_exist = 1
filename_expected = 2
communication_error = 3
ole_object_method_error = 4
ole_object_property_error = 5
invalid_filename = 6
invalid_pivot_fields = 7
download_problem = 8
others = 9.
endform.
Reward if useful
Regards,
Narasimha
Edited by: narasimha marella on May 13, 2008 12:12 PM -
How do we handle BDC table control
hi sap technical guru,
PLS suggest me how to handle BDC table control while uploading data to sap R/3
regards,Hi,
First take BDC recording for required transaction from SHDB then you will find screen field names, screen numbers sequence, According to that pass values to below BDC_DYNPRO and BDC_FIELD forms and append data to BDC table. In my requirement I have done this for VB03 transaction passed values to VB03 transaction from my selection screen.
*& Report ZS_VB03_TRANSACTION
REPORT ZS_VB03_TRANSACTION.
TABLES: KOMGG, "Dialogkommunikationstab
T685T, "Text zum Konditionsart
T185F, "Folgebildsteurung
T681, "Konditionstabelle
TMC1T, G000, TPARA. "Kurztext zur Konditionstabell
* Sales Organization *
SELECT-OPTIONS S_F001 FOR KOMGG-VKORG.
*MEMORY ID VKO.
* Distribution Channel *
SELECT-OPTIONS S_F002 FOR KOMGG-VTWEG
MEMORY ID VTW.
* Division *
SELECT-OPTIONS S_F003 FOR KOMGG-SPART
MEMORY ID SPA.
* CustomerHierarchy 01 *
SELECT-OPTIONS S_F004 FOR KOMGG-HIENR01.
* Material *
SELECT-OPTIONS S_F005 FOR KOMGG-MATNR
MEMORY ID MAT
MATCHCODE OBJECT MAT1.
* Customer *
SELECT-OPTIONS S_F006 FOR KOMGG-KUNNR
MEMORY ID KUN
MATCHCODE OBJECT DEBI.
* "Selektionsdatum *
SELECTION-SCREEN SKIP 1.
PARAMETERS SEL_DATE LIKE RV130-DATAM
DEFAULT SY-DATLO.
PARAMETERS: r_vb03 TYPE c RADIOBUTTON GROUP rb1 DEFAULT 'X',
r2 type c RADIOBUTTON GROUP rb1.
* * Batchinputdata of single transaction
DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
* messages of call transaction
DATA: MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
data: lv TYPE i.
data: s1 type KOMGG-VKORG,
s2 type KOMGG-VKORG.
START-OF-SELECTION.
if r_vb03 = 'X'.
data: num(2) TYPE n VALUE '01',
lv_string(40) type c,
lv_s_f001 like s_f001.
set PARAMETER ID: 'VGK' FIELD 'A001'. "Place ur default value here in A001 place.
If S_f001-high is INITIAL.
perform bdc_field using 'BDC_CURSOR'
'F001-LOW'.
perform bdc_field using 'BDC_OKCODE'
'=%003'.
perform bdc_dynpro using 'SAPLALDB' '3000'.
perform bdc_field using 'BDC_OKCODE'
'=ACPT'.
perform bdc_field using 'BDC_CURSOR'
'RSCSEL-SLOW_I(01)'.
loop at S_f001 into lv_s_f001.
CONCATENATE 'RSCSEL-SLOW_I(' num ')' INTO lv_string.
perform bdc_field using 'BDC_CURSOR'
lv_string.
perform bdc_field using lv_string
lv_s_f001-low.
clear: lv_s_f001, lv_string.
num = num + 1.
ENDLOOP.
clear num.
perform bdc_dynpro using 'RV13GAAB' '1000'.
perform bdc_field using 'BDC_CURSOR'
'F002-LOW'.
ELSE.
perform bdc_dynpro using 'RV13GAAB' '1000'.
perform bdc_field using 'BDC_CURSOR'
'F001-LOW'.
perform bdc_field using 'F001-LOW' S_f001-low.
perform bdc_field using 'F001-HIGH' S_f001-high.
endif.
perform bdc_field using 'F002-LOW' S_F002-low.
perform bdc_field using 'F002-HIGH' S_F002-High.
perform bdc_field using 'F004-high' S_F004-high.
perform bdc_field using 'F005-LOW' S_F005-low.
perform bdc_field using 'F003-LOW' S_F003-low.
perform bdc_field using 'F003-High' S_F003-high.
perform bdc_field using 'F004-LOW' S_F004-low.
perform bdc_field using 'F005-high' S_F005-high.
perform bdc_field using 'F006-LOW' S_F006-low.
perform bdc_field using 'F006-high' S_F006-high.
call TRANSACTION 'VB03' USING BDCDATA MODE 'E' MESSAGES INTO MESSTAB.
ENDIF.
* 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.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
ENDFORM. -
Code for va01 bdc table control
hi
i want to CODE FOR bdc table control VA01 (TCODE)
ASAPAwadhesh,
just refer:
Problem in the BDC Table Control for the T.Code VA01
BDC Uploading from flat file to VA01.
BDC For Line Items In Sales Order
dont forget reward.
Amit. -
hi friends,
Could u please tell me what BDC TABLE CONTROLER
in which cases we can use the bdc Table Contorler
Regards
srinu yHi srinu,
<b>Check this link</b>
http://www.sap-basis-abap.com/abap/handling-table-control-in-bdc.htm
How to deal with table control / step loop in BDC
<b>Steploop</b> and <b>table contol</b> is inevitable in certain transactions. When we run BDC for such transactions, we will face the situation: how many visible lines of steploop/tablecontrol are on the screen? Although we can always find certain method to deal with it, such as function code 'NP', 'POPO', considering some extreme situation: there is only one line visible one the screen, our BDC program should display an error message. (See transaction 'ME21', we you resize your screen to let only one row visible, you can not enter mutiple lines on this screen even you use 'NP')
Now with the help of Poonam on sapfans.com developement forum, I find a method with which we can determine the number of visible lines on Transaction Screen from our Calling BDC program. Maybe it is useless to you, but I think it will give your some idea.
Demo <b>ABAP code</b> has two purposes:
<b>1.</b> how to determine number of visible lines and how to calculte page number;
(the 'calpage' routine has been modify to meet general purpose usage)
<b>2.</b> using field symbol in BDC program, please pay special attention to the difference in Static ASSIGN and Dynamic ASSIGN.
Now I begin to describe the step to implement my method:
(I use transaction 'ME21', screen 121 for sample,
the method using is Call Transation Using..)
<b>Step1:</b> go to screen painter to display the screen 121, then we can count the fixed line on this screen, there is 7 lines above the steploop and 2 lines below the steploop, so there are total 9 fixed lines on this screen. This means except these 9 lines, all the other line is for step loop. Then have a look at steploop itselp, one entry of it will occupy two lines.
(Be careful, for table control, the head and the bottom scroll bar will possess another two fixed lines, and there is a maximum number for table line)
Now we have : FixedLine = 9
LoopLine = 2(for table control, LoopLine is always equal to 1)
<b>Step2:</b> go to transaction itself(ME21) to see how it roll page, in ME21, the first line of new page is always occupied by the last line of last page, so it begin with index '02', but in some other case, fisrt line is empty and ready for input.
Now we have: FirstLine = 0
or FirstLine = 1 ( in our case, FirstLine is 1 because the first line of new page is fulfilled)
<b>Step3:</b> write a subroutine calcalculating number of pages
(here, the name of actual parameter is the same as formal parameter)
<b>global data:</b> FixedLine type i, " number of fixed line on a certain screen
LoopLine type i, " the number of lines occupied by one steploop item
FirstLine type i, " possbile value 0 or 1, 0 stand for the first line of new " scrolling screen is empty, otherwise is 1
Dataline type i, " number of items you will use in BDC, using DESCRIBE to get
pageno type i, " you need to scroll screen how many times.
line type i, " number of lines appears on the screen.
index(2) type N, " the screen index for certain item
begin type i, " from parameter of loop
end type i. " to parameter of loop
*in code sample, the DataTable-linindex stands for the table index number of this line
form calpage using FixedLine type i (see step 1)
LoopLine type i (see step 1)
FirstLine type i (see step 2)
DataLine type i ( this is the item number you will enter in transaction)
changing pageno type i (return the number of page, depends on run-time visible line in table control/ Step Loop)
changing line type i.(visible lines one the screen)
data: midd type i,
vline type i, "visible lines
if DataLine eq 0.
Message eXXX.
endif.
vline = ( sy-srows - FixedLine ) div LoopLine.
*for table control, you should compare vline with maximum line of
*table control, then take the small one that is min(vline, maximum)
*here only illustrate step loop
if FirstLine eq 0.
pageno = DataLine div vline.
if pageno eq 0.
pageno = pageno + 1.
endif.
elseif FirstLine eq 1.
pageno = ( DataLine - 1 ) div ( vline - 1 ) + 1.
midd = ( DataLine - 1 ) mod ( vline - 1).
if midd = 0 and DataLine gt 1.
pageno = pageno - 1.
endif.
endif.
line = vline.
endform.
<b>Step4</b> write a subroutine to calculate the line index for each item.
form calindex using Line type i (visible lines on the screen)
FirstLine type i(see step 2)
LineIndex type i(item index)
changing Index type n. (index on the screen)
if FirstLine = 0.
index = LineIndex mod Line.
if index = '00'.
index = Line.
endif.
elseif FirstLine = 1.
index = LineIndex mod ( Line - 1 ).
if ( index between 1 and 0 ) and LineIndex gt 1.
index = index + Line - 1.
endif.
if Line = 2.
index = index + Line - 1.
endif.
endif.
endform.
<b>Step5</b> write a subroutine to calculate the loop range.
form calrange using Line type i ( visible lines on the screen)
DataLine type i
FirstLine type i
loopindex like sy-index
changing begin type i
end type i.
If FirstLine = 0.
if loopindex = 1.
begin = 1.
if DataLine <= Line.
end = DataLine.
else.
end = Line.
endif.
elseif loopindex gt 1.
begin = Line * ( loopindex - 1 ) + 1.
end = Line * loopindex.
if end gt DataLine.
end = DataLine.
endif.
endif.
elseif FirstLine = 1.
if loopindex = 1.
begin = 1.
if DataLine <= Line.
end = DataLine.
else.
end = Line.
endif.
elseif loop index gt 1.
begin = ( Line - 1 ) * ( loopindex - 1 ) + 2.
end = ( Line - 1 ) * ( loopindex - 1 ) + Line.
if end gt DataLine.
end = DataLine.
endif.
endif.
endif.
endform.
<b>Step6</b> using field sysbol in your BDC, for example: in ME21, but you should calculate each item will correponding to which index in steploop/Table Control
form creat_bdc.
field-symbols: <material>, <quan>, <indicator>.
data: name1(14) value 'EKPO-EMATN(XX)',
name2(14) value 'EKPO-MENGE(XX)',
name3(15) value 'RM06E-SELKZ(XX)'.
assign: name1 to <material>,
name2 to <quan>,
name3 to <indicator>.
do pageno times.
if sy-index gt 1
*insert scroll page ok_code"
endif.
perform calrange using Line DataLine FirstLine sy-index
changing begin end.
loop at DataTable from begin to end.
perform calindex using Line FirstLine DataTable-LineIndex changing Index.
name1+11(2) = Index.
name2+11(2) = Index.
name3+12(2) = Index.
perform bdcfield using <material> DataTable-matnr.
perform bdcfield using <quan> DataTable-menge.
perform bdcfield using <indicator> DataTable-indicator.
endloop.
enddo.
Reward with points if it is helpful
Cheers
Alfred -
Problem in the BDC Table Control for the T.Code VA01
Hi,
I faced probelm in the BDC of the VA01. In the Table Control
the records are entered upto 12 line items. after 13th line item overwrites the first record. How to solve the Problem.
Please help me.or use this
Internal table definition *
data : begin of bdcdata occurs 0.
include structure bdcdata.
data : end of bdcdata.
data: begin of messtab occurs 0.
include structure bdcmsgcoll.
data: end of messtab.
data: v_chr_opengrp type c,
r_matnr like mara-matnr, "variable for material conversion
r_werks like marc-werks, "variable for plant
v_str_fname type string.
data: begin of count2,
inrec(9) type n, " input I_MATERIAL count
create(9) type n, " create count
error(9) type n, " error count
bdc(9) type n, " count of BDC creates
end of count2.
types: begin of ty_source,
partn_numb(10) type n ,"Customer Number 1
ref(035),
sales_org(4) , "Sales Organization
distr_chan(2) , "Distribution Channel
division(002), "DIVISION
doc_type(4) , "Sales Document Type
purch_no(020), "Purchase order
material like vbap-matnr,
reqqty(018),
reqdate(010),
end of ty_source,
begin of ty_header ,
partn_numb(10) ,"Customer Number 1
ref(035),
sales_org(4) , "Sales Organization
distr_chan(2) , "Distribution Channel
division(002), "DIVISION
doc_type(4) , "Sales Document Type
purch_no(020), "Purchase order
end of ty_header,
begin of ty_item,
partn_numb(10) ,"Customer Number 1
ref(035),
material like vbap-matnr,
reqqty(018),
reqdate(010),
end of ty_item.
data : msg(240) type c, " Return Message
e_rec(8) type c, " Error Records Counter
rec_no(8) type c, " Records Number Indicator
s_rec(8) type c, " Successful Records Counter
t_rec(8) type c, " Total Records Counter
v_matnr like mara-matnr.
data: val(2) type n value 01.
data : begin of bdc_itab occurs 0.
include structure bdcdata.
data : end of bdc_itab.
data : t_source type standard table of ty_source with header line,
t_header type standard table of ty_header initial size 1,
t_item type standard table of ty_item initial size 1,
t_target type standard table of bdcdata initial size 1.
data : w_source type ty_source,
w_source1 type ty_source,
w_header type ty_header,
w_item type ty_item,
w_target type bdcdata,
count type i,
count1 type n.
Variable Declaration
data: w_fname type string,
fnam(20),
date1(10),
i(2) type n,
v_count type i,
v_group type apqi-groupid.
*& selection screen
selection-screen :begin of block bl1 with frame title text-001.
parameters : p_fname type rlgrap-filename, "Input file
p_update(1) default 'N', "Input for update mode
p_bdcgrp(12) default 'SD_ORDERS'. "Input for session name
selection-screen end of block bl1.
**&SELECTION SCREEN VALIDATIONS
at selection-screen on value-request for p_fname.
call function 'KD_GET_FILENAME_ON_F4'
exporting
program_name = 'ZMATERIAL'
dynpro_number = '1000'
field_name = 'P_FNAME'
changing
file_name = p_fname.
*& Start of selection
start-of-selection.
if p_fname is initial.
message i016(rp) with 'Please enter a file name'.
leave list-processing.
else.
move p_fname to v_str_fname.
endif.
call function 'GUI_UPLOAD'
exporting
filetype = 'ASC'
filename = v_str_fname
has_field_separator = 'X'
tables
data_tab = t_source
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.
sort t_source by ref partn_numb.
loop at t_source into w_source.
add 1 to count2-inrec.
w_source1 = w_source.
AT NEW PARTN_NUMB. "10/31 KVB
at new ref.
w_header-doc_type = w_source1-doc_type..
w_header-sales_org = w_source1-sales_org . "'0001'
w_header-distr_chan = w_source1-distr_chan. "'01'
w_header-division = w_source1-division. " '01'
w_header-purch_no = w_source1-purch_no.
w_header-partn_numb = w_source1-partn_numb.
w_header-ref = w_source1-ref.
append w_header to t_header.
endat.
w_item-partn_numb = w_source1-partn_numb.
w_item-material = w_source1-material.
w_item-reqqty = w_source1-reqqty.
w_item-ref = w_source1-ref.
w_item-reqdate = w_source1-reqdate.
append w_item to t_item.
clear :w_item,w_header.
endloop.
loop at t_header into w_header.
perform bdc_dynpro using 'SAPMV45A' '0101' .
perform bdc_field using 'BDC_CURSOR' 'VBAK-SPART'.
perform bdc_field using 'BDC_OKCODE' '/00'.
perform bdc_field using 'VBAK-AUART' w_header-doc_type.
perform bdc_field using 'VBAK-VKORG' w_header-sales_org.
perform bdc_field using 'VBAK-VTWEG' w_header-distr_chan.
perform bdc_field using 'VBAK-SPART' w_header-division.
perform bdc_dynpro using 'SAPMV45A' '4001' .
perform bdc_field using 'BDC_OKCODE' '/00'.
perform bdc_field using 'BDC_CURSOR' 'VBKD-BSTKD'.
perform bdc_field using 'VBKD-BSTKD' w_header-purch_no.
perform bdc_field using 'KUWEV-KUNNR' w_header-partn_numb.
i = 1.
loop at t_item into w_item where partn_numb = w_header-partn_numb
and ref = w_header-ref.
at new partn_numb.
clear count1.
count = 0.
endat.
count = count + 1.
if count gt 5.
clear i.
i = 2.
perform bdc_dynpro using 'SAPMV45A' '4001' .
perform bdc_field using 'BDC_OKCODE' '=POAN'.
endif.
count1 = count1 + 1.
concatenate 'VBAP-POSNR(' i ')' into fnam.
perform bdc_field using fnam
count1.
concatenate 'RV45A-MABNR(' i ')' into fnam.
perform bdc_field using fnam w_item-material.
concatenate 'RV45A-KWMENG(' i ')' into fnam.
perform bdc_field using fnam w_item-reqqty..
concatenate 'RV45A-ETDAT(' i ')' into fnam.
perform bdc_field using fnam w_item-reqdate.
concatenate 'VBKD-BSTKD_E(' i ')' into fnam.
perform bdc_field using fnam w_item-ref.
i = i + 1.
clear: w_item.
endloop.
clear w_header.
perform bdc_dynpro using 'SAPMV45A' '4001'.
perform bdc_field using 'BDC_OKCODE'
'=SICH'.
perform post_transaction.
refresh bdc_itab.
clear bdc_itab.
endloop.
*endloop.
end-of-selection.
perform finalization.
Start new screen *
form bdc_dynpro using program dynpro.
clear bdc_itab.
bdc_itab-program = program.
bdc_itab-dynpro = dynpro.
bdc_itab-dynbegin = 'X'.
append bdc_itab.
endform. "bdc_dynpro
Insert field *
form bdc_field using fnam fval.
if fval <> ''.
clear bdc_itab.
bdc_itab-fnam = fnam.
bdc_itab-fval = fval.
append bdc_itab.
endif.
endform. "bdc_field
**& Form get_filename
text
--> p1 text
<-- p2 text
*form get_filename .
*call function 'WS_FILENAME_GET'
exporting
def_filename = space
def_path = file
mask = ',.,..'
mode = 'N'
title = text-015
importing
filename = file
exceptions
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
others = 5.
*endform. " get_filename
*& Form post_transaction
text
--> p1 text
<-- p2 text
form post_transaction .
refresh messtab.
clear messtab.
call transaction 'VA01' using bdc_itab
mode p_update
update 'S'
messages into messtab.
read table messtab with key msgtyp = 'E'.
if sy-subrc eq 0.
perform process_error_messages.
add 1 to count2-bdc.
if v_chr_opengrp is initial.
perform bdc_open_group.
endif.
call function 'BDC_INSERT'
exporting
tcode = 'VA01'
tables
dynprotab = bdc_itab
exceptions
internal_error = 1
not_open = 2
queue_error = 3
tcode_invalid = 4
others = 5.
if sy-subrc <> 0.
case sy-subrc.
when 1.
write: / 'Internal error'.
when 2.
write: / 'Not open error'.
when 3.
write: / 'queue error'.
when 4.
write: / 'tcode invalid error'.
when others.
write: / 'other error'.
endcase.
endif.
else.
add +1 to count2-create.
format intensified off.
format color col_normal.
format color col_normal off.
endif.
clear bdc_itab.
refresh bdc_itab.
endform. " post_transaction
*& Form finalization
text
--> p1 text
<-- p2 text
form finalization .
if v_chr_opengrp = 'X'.
call function 'BDC_CLOSE_GROUP'
exceptions
not_open = 1
queue_error = 2
others = 3.
endif.
get time.
skip 2.
write: / 'Time', sy-uzeit.
skip.
format color col_total on.
write: / 'Total Records: ', 40 count2-inrec.
write: / 'PERNR not of Emp Group 6 ', 40 count2-error.
write: / 'Records Created: ', 40 count2-create.
write: / 'BDC Create in group: ', 40 count2-bdc.
if v_chr_opengrp = 'X'.
skip 1.
format intensified on.
format color col_negative on.
write: / 'PLEASE USE TRANSACTION "SM35" ',
'TO PROCESS THE GENERATED BDC SESSION ... ',
p_bdcgrp.
endif.
endform. " finalization
*& Form bdc_open_group
text
--> p1 text
<-- p2 text
form bdc_open_group .
call function 'BDC_OPEN_GROUP'
exporting
client = sy-mandt
group = p_bdcgrp
holddate = sy-datum
keep = 'X'
user = sy-uname
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 eq 0.
v_chr_opengrp = 'X'.
endif.
endform. " bdc_open_group
*& Form process_error_messages
text
--> p1 text
<-- p2 text
form process_error_messages .
data: begin of loc_aux_message.
include structure message.
data: end of loc_aux_message.
data : msgno type sy-msgno.
loop at messtab.
move messtab-msgnr to msgno.
call function 'WRITE_MESSAGE'
exporting
msgid = messtab-msgid
msgno = msgno
msgty = messtab-msgtyp
msgv1 = messtab-msgv1
msgv2 = messtab-msgv2
msgv3 = messtab-msgv3
msgv4 = messtab-msgv4
importing
messg = loc_aux_message
exceptions
others = 1.
if sy-subrc eq 0.
format color col_negative on.
write: /10 loc_aux_message.
format color col_negative off.
else.
format color col_negative on.
write: /10 t_source-partn_numb.
write: / 'Error creating message'.
format color col_negative off.
exit.
endif.
endloop.
endform. " process_error_messages -
hi
In BDC how to transfer the data to table controlhi
what ever the data that u want to trnasfer to table ctrl, put it in a flat file.
create an internal able that can occupy those datas.
then transfer from internal table to table control.
ex: for me41/.
REPORT YELS_ME41_BDC_V NO STANDARD PAGE HEADING LINE-SIZE 255.
INCLUDE BDCRECX1.
INTERNAL TABLE DECLARATION.
DATA : BEGIN OF ITAB OCCURS 0,
V_NUM(3) TYPE C,"SERIAL NUMBER
EMATN LIKE EKPO-EMATN,
TXZ01 LIKE EKPO-TXZ01,
ANMNG(13) TYPE C,
MEINS(3) TYPE C,
LPEIN LIKE RM06E-LPEIN,
EEIND LIKE RM06E-EEIND,
MATKL LIKE EKPO-MATKL,
END OF ITAB.
VARIABLE DECLARATION
DATA : V_LASTNUM(3) TYPE C,
V_TEMPVAR(15),
V_PAGES(3) TYPE C VALUE '10',
V_COUNT TYPE I,
V_CTR TYPE I,
V_TCTR(2) TYPE C,
V_TEST TYPE C VALUE 0,
ITEM LIKE RM06E-EBELP.
*DATA: BDCDATA TYPE BDCDATA OCCURS 0 WITH HEADER LINE.
BEGIN OF PROGRAM.
START-OF-SELECTION.
PERFORM GET-DATA.
SORT ITAB BY NUM EEIND.
PERFORM OPEN_GROUP.
*DATA TRANSFERRED FROM INTERNAL TABLE TO IST 2ND SCREEN FIELDS(HEADER
*DATA)
LOOP AT ITAB.
IF ITAB-V_NUM NE V_LASTNUM.
" HEADER DATA EXECUTES FOR ONLY ONE TIME FOR ONE RFQ GENERATION
WHEN SNO IS NOT EQUAL TO LASTNUMBER. THEN PROCEED.
V_TEST = 0.
PERFORM BDC_DYNPRO USING 'SAPMM06E' '0300'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'EKKO-ANGDT'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'RM06E-ASART'
'AN'. "RFQ TYPE.
PERFORM BDC_FIELD USING 'EKKO-SPRAS'
'EN'. " LANGUAGE KEY.
PERFORM BDC_FIELD USING 'RM06E-ANFDT'
'19.07.2007'."RFQ DATE.
PERFORM BDC_FIELD USING 'EKKO-ANGDT'
'29.07.2007'."QUOTATION DEAD LINE.
PERFORM BDC_FIELD USING 'EKKO-EKORG'
'3000'."PURCHASE ORGANISATION.
PERFORM BDC_FIELD USING 'EKKO-EKGRP'
'003'."PURCHASE GROUP.
PERFORM BDC_FIELD USING 'RM06E-LPEIN'
'T'.
IIND SCREEN.
PERFORM BDC_DYNPRO USING 'SAPMM06E' '0301'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'EKKO-SUBMI'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'BU'.
PERFORM BDC_FIELD USING 'EKKO-EKGRP'
'003'.
PERFORM BDC_FIELD USING 'EKKO-PINCR'
'10'." ITEM INTERVAL.
PERFORM BDC_FIELD USING 'EKKO-SUBMI'
'1'." COLL NO.
PERFORM BDC_FIELD USING 'EKKO-SPRAS'
'EN'.
PERFORM BDC_FIELD USING 'EKKO-UPINC'
'1'." SUB ITEM INTERVAL.
PERFORM BDC_FIELD USING 'EKKO-ANGDT'
'29.07.2007'.
PERFORM BDC_DYNPRO USING 'SAPMM06E' '0301'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'EKKO-EKGRP'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'EKKO-EKGRP'
'003'.
PERFORM BDC_FIELD USING 'EKKO-PINCR'
'10'.
PERFORM BDC_FIELD USING 'EKKO-SUBMI'
'1'.
PERFORM BDC_FIELD USING 'EKKO-UPINC'
'1'.
PERFORM BDC_FIELD USING 'EKKO-ANGDT'
'29.07.2007'.
**********tab ctrl*********************************************
IIIRD SCREEN
PERFORM BDC_DYNPRO USING 'SAPMM06E' '0320'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RM06E-EEIND(01)'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'EKKO-ANGDT'
'29.07.2007'.
DATA MOVED FROM INTERNAL TABLE TO TABLE CONTROL
V_CTR = 0.
"FOR ONE RFQ , MORE ITEMS WILL BE THERE. COUNT STARTS HERE.
LOOP AT ITAB WHERE V_NUM = ITAB-V_NUM." CHECK THE SNO IS EQUAL .
V_CTR = V_CTR + 1." COUNT IS INCREMENTED BY 1.
MY TAB CTRL CAN HAVE ONLY 20 RECORDS.
IF COUNT IS LESS THAN OR EQUAL TO 20 ASSIGN THIS VALUE TO TCTR VAR
IF V_CTR <= 20.
V_TCTR = V_CTR.
ENDIF.
*IF COUNT IS GREATER THAN 20 ASSIGN THIS VALUE TO TCTR VAR
IF V_CTR > 20.
V_TCTR = '20'.
ENDIF.
IF COUNT IS LESS THAN OR EQUAL TO 10 BLANK SPACE IS ALLOTTED TO TEST
VAR.
IF V_CTR >= 10.
V_TEST = ''.
ENDIF.
WHEN COUNT IS LESS THAN 20 THEN ITEM (PAGES) WILL BE 10.
IF V_CTR < 20.
V_PAGES = 10.
PERFORM BDC_FIELD USING 'RM06E-EBELP'
V_PAGES.
ENDIF.
WHEN COUNT IS GREATER THAN 20 THEN ITEM (PAGES) WILL BE INCREMENTED BY
10 FOR EVERY ENTRY..
IF V_CTR >= 20.
V_PAGES = V_PAGES + 10.
PERFORM BDC_FIELD USING 'RM06E-EBELP'
V_PAGES.
ENDIF.
CONCTAENATION IS DONE TO GET A PATTERN LIKE EKPO-EMATN(01).
UPLOAD EMATN FIELD INTO TABLE CONTROL
CONCATENATE 'ekpo-ematn(' V_TEST V_TCTR ')' INTO V_TEMPVAR.
CONDENSE V_TEMPVAR NO-GAPS.
PERFORM BDC_FIELD USING V_TEMPVAR ITAB-EMATN.
UPLOAD SHORT TEXT FIELD INTO TABLE CONTROL
CONCATENATE 'ekpo-txz01(' V_TEST V_TCTR ')' INTO V_TEMPVAR.
CONDENSE V_TEMPVAR NO-GAPS.
PERFORM BDC_FIELD USING V_TEMPVAR ITAB-TXZ01.
UPLOAD QUANTITY FIELD INTO TABLE CONTROL
CONCATENATE 'rm06e-anmng(' V_TEST V_TCTR ')' INTO V_TEMPVAR.
CONDENSE V_TEMPVAR NO-GAPS.
PERFORM BDC_FIELD USING V_TEMPVAR ITAB-ANMNG.
UPLOAD UNIT OF MEASURE FIELD INTO TABLE CONTROL
CONCATENATE 'ekpo-meins(' V_TEST V_TCTR ')' INTO V_TEMPVAR.
CONDENSE V_TEMPVAR NO-GAPS.
PERFORM BDC_FIELD USING V_TEMPVAR ITAB-MEINS.
UPLOAD DATE FORMAT FIELD INTO TABLE CONTROL
CONCATENATE 'rm06e-lpein(' V_TEST V_TCTR ')' INTO V_TEMPVAR.
CONDENSE V_TEMPVAR NO-GAPS.
PERFORM BDC_FIELD USING V_TEMPVAR ITAB-LPEIN.
UPLOAD DATE FIELD INTO TABLE CONTROL
CONCATENATE 'rm06e-eeind(' V_TEST V_TCTR ')' INTO V_TEMPVAR.
CONDENSE V_TEMPVAR NO-GAPS.
PERFORM BDC_FIELD USING V_TEMPVAR ITAB-EEIND.
UPLOAD MATERIAL GROUP FIELD INTO TABLE CONTROL
CONCATENATE 'EKPO-MATKL(' V_TEST V_TCTR ')' INTO V_TEMPVAR.
CONDENSE V_TEMPVAR NO-GAPS.
PERFORM BDC_FIELD USING V_TEMPVAR ITAB-MATKL.
PERFORM BDC_DYNPRO USING 'SAPMM06E' '0320'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'EKKO-ANGDT'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=LS'.
PERFORM BDC_FIELD USING 'EKKO-ANGDT'
'29.07.2007'.
*AFTER INSERTING ONE ROW OF DATA PRESS ENTER .CURSOR SHOULD BE AT DEAD
*LINE DATE.
CONCATENATE 'ekpo-ematn(' V_TEST V_TCTR ')' INTO V_TEMPVAR.
CONDENSE V_TEMPVAR NO-GAPS.
PERFORM BDC_FIELD USING 'BDC_CURSOR' V_TEMPVAR.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
ENDLOOP.
*************************vendor addr*******************
V_LASTNUM = ITAB-V_NUM.
*******ENTER VENDOR NUMBER AND SAVE.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_DYNPRO USING 'SAPMM06E' '0140'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'EKKO-LIFNR'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'EKKO-LIFNR'
'9054'." VENDOR NUMBER.
PERFORM BDC_DYNPRO USING 'SAPLMEXF' '0100'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTE'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RM06E-SPRAS'.
PERFORM BDC_FIELD USING 'BUTTON_INIT'
'X'.
PERFORM BDC_DYNPRO USING 'SAPMM06E' '0140'.
PERFORM BDC_DYNPRO USING 'SAPMM06E' '0140'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'EKKO-LIFNR'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=BU'.
PERFORM BDC_FIELD USING 'EKKO-LIFNR'
'9054'.
PERFORM BDC_FIELD USING 'ADDR1_DATA-NAME1'
'tttt'.
PERFORM BDC_FIELD USING 'ADDR1_DATA-SORT1'
'TT'.
PERFORM BDC_FIELD USING 'ADDR1_DATA-COUNTRY'
'AZ'.
PERFORM BDC_DYNPRO USING 'SAPLSPO1' '0300'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=YES'.
PERFORM BDC_TRANSACTION USING 'ME41'.
REFRESH BDCDATA.
ENDIF.
ENDLOOP.
PERFORM CLOSE_GROUP.
*& Form get-data
UPLOAD FLAT FILES TO INTERNAL TABLE.
FORM GET-DATA.
*TRANSFER DATA FROM FLAT FILE TO INTERNAL TABLE.
CALL FUNCTION 'UPLOAD'
EXPORTING
CODEPAGE = ' '
FILENAME = ' '
FILETYPE = ' '
ITEM = ' '
FILEMASK_MASK = ' '
FILEMASK_TEXT = ' '
FILETYPE_NO_CHANGE = ' '
FILEMASK_ALL = ' '
FILETYPE_NO_SHOW = ' '
LINE_EXIT = ' '
USER_FORM = ' '
USER_PROG = ' '
SILENT = 'S'
IMPORTING
FILESIZE =
CANCEL =
ACT_FILENAME =
ACT_FILETYPE =
TABLES
DATA_TAB = ITAB
EXCEPTIONS
CONVERSION_ERROR = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 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. "get-data
reward if useful -
BDC: Table Control Screen Resolution
Hi Abapers,
1.In BDC while handling table control , how to handle screen resolution , that means in some systems i can see 5 item entries , in some systems i can see 10 item entries how to handle this , can u send the Code relating this.
With Regards
Bhaskar Rao.Mhi
The numeber of lines of table control for BDC depend on screen resolution, but It can't be managed by program.
So the better solution is to create a bdc doesn't depend on resolution.
It can do that using always the first two lines of table control.
When you start the simulation, first record has to be placed in first line of tc and the second in second one.
Before placing the third record, it needs to place the second record to the top and so the third record can be placed in the second line.
Before placing the next record, it needs to place the third record to the top and so the fourth record can be placed in the second line and so.
In this way your BDC'll use alwways the first two lines of tc and your program won't depend on resolution.
The problem is the transaction you need to simulate by BDC has to have a scroll functionality to allow to place the last record was elaborated to the top of tc, so the second line of tc can always be used to place the new record.
If there isn't this functionality, it's better to use a BAPI instead of BDC.
check these two
BDC - standard screen resolution required?
https://forums.sdn.sap.com/click.jspa?searchID=739193&messageID=823953
reward points if found helpful -
hi gurus ,
can any one explain about ' P++' concept about handling of table control in bdc.
with regards
aru.Note these-->
P- : Back
P-- : Scroll to previous page
P+ : Scroll to next page
<b>P++ Scroll to last page</b>
PL- : Scroll to first line in page
PL-n : Scroll back n lines
PL+ : Scroll to last line in page
PL+n Scroll forward n lines
PP- : Scroll back one page
PP-n Scroll back n pages
PP+ scroll forward one page
PP+n : scroll forward n page
PPn : Scroll to start of page n
Ps- : Scroll to first column
PS++ Scroll to last column
regards,
srinivas
*reward for useful answers* -
BDC - table control - experts please help
Hi experts,
Please help. I am in need of your help.
I am working with BDC and I have a table control in one of the screen. Table control has a check box in the first column. While recording how I entered the data is : I select the check box in a row, enter two values in next two columns of that row and then hit enter then the other columns in that row turn from grey to white (initially these columns are greyed out).
NOw in BDC when I run my session in foreground, I am able to check(select) the check box and enter the values in next two columns and then I have a Enter OKCODE. But when I hit enter it is not able to recognize the row and its unable to turn the greyed out columns in that particular row to white.
Is there a way to specify in my program that I am hitting enter in one particular row.
Please help. Let me know if something is not clear. Very urgent . Pleasee respond. ThanksHi Rich,
Thanks for the replies. I will try that. I got one more doubt. While manually creating the recipes using C201, there is a screen Recipe header. When I record this transaction, I see a different screen for the Recipe header. Fro example the screen numbers are like 4210(manual) and 4211(recording).
But my problem is there are two fields which are missing in the screen which I am getting while recording C201. These two fields are present on the screen for manual creation. I need to enter those two fields while I record. But how can I do this.
Please help. -
How to use Page down functionality in BDC Table control
Hi Guys,
I am facing problem with populating data in the table control at item level. I am able to poulate upto 6 records, i need to populate n number of records.
Pls help me with using P+ functionality for table control in BDC.
Thanks in advance
SatishHi!
Can you share how you got this solved?
Thanks! -
Problem in BDC table control for t.code ABAVN
Facing problem in uploading asset numbers.
Requirement: - Uploading data to transaction code ABAVN.
1. After running the transaction click on multiple assets.
2. Then we enter first four fields i.e. Document date, posting date, asset value date and text.
3. After that we make entry in the list of assets field say around 200 asset numbers so that it generates only one document number.
Problem: - As I was working with BDC the problem I faced is in recording. After entering six asset numbers I have to press enter to activate the scroll bar, as I click scroll down it records full screen fields for every single scroll.
Thanks and regards,
Vishal Divekar.Hi Vishal ,
please check <b>BAPI_ASSET_RETIREMENT_POST</b>and see the Documentation for more info.
Regards
Prabhu -
How to upload material text in mm02 using bdc table control
i have problem to upload material Description in mm02 using bdc.
my text file is like
2000251 AF A12345
2000251 AR B12345
2000251 BG C12345
2000252 AF F12345
2000252 AR G12345
2000252 AF H12345
i want to upload material number, language, and material description, how can i upload pls help me.Hi,
Try with bapi , bapi_material_save_data.. didn't exactly remember it,Please check the same.
Regards,
Nagaraj -
How to transfer data in table control in bdc
hi
how to transfer data in table control in bdc . I need the theory regarding this
byeHi,
just check in the forum , there is many threads available to ur questions.
Table control in BDC
http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
You can even refer to these related threads
bdc table control
Re: table control in bdc
table control in BDC
Reward if helpful.
Thanks
Naveen khan
Maybe you are looking for
-
Hi all, i need to create multiprovider combining cube and ods. i created MP and when i view the data in listcube, data is populated from cube . ods data didnt populated in MP. eventhough i mapped common chars from two infoproviders MP, data is not po
-
in mail, my inbox screen was split, with the messages in the top portion ( from: subject: date received: mailbox) & the info from the highlighted mesage in the bottom portion. Currently I've "lost" the split screen and must double clikc the message w
-
Dead pixels appeared on Macbook Pro Retina 15"
Hi, Bought my Macbook on September / 2014 and so far no problems. Unfortunately today a lot of dead pixels appeared on the center of my screen ! I tried to clean it but it seems to be behind the screen actually. Tried to reboot and reset SMC as reque
-
How do I add music to play on my entire site?
Hi!! Pretty green at this stuff so bear with me!! Designing a website for my small business and would LOVE to add music that could play through the entire site rather than on the page the media is placed on.. does that make any sense to anyone? Thank
-
Error while raising sales order
Hi all, I have created a make-to-order material with item category group and general item cetegory group 0001. While raising sales order for that material (make-to-order) item category TAK. I got a error stating that plant is not assigned to controll