Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

how to create screen resolution in bdc table control

Former Member
0 Kudos

hi gurus

can anyone suggest me

how to create screen resolution in bdc table control

thanks&regards

mark.

1 REPLY 1

Former Member
0 Kudos

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