More than 1 line items in bdc using table controls for BOM
Hi....
how do u update more than one line item for BOM using BDC table control.......
is there any specific command for doing that.......
hav tried d following code bt it takes the flatfile i/p FOR 2 LINE ITEMS as 2 different BOM'S.....
would appreciate ur help....plz provide code.............
REPORT zbdc4_cs01
NO STANDARD PAGE HEADING LINE-SIZE 255.
INCLUDE bdcrecx1.
DATA : a TYPE i,
b type i,
c type i.
DATA : BEGIN OF it_rec OCCURS 0,
rec(200) TYPE c,
END OF it_rec.
DATA : BEGIN OF ctab OCCURS 0,
matnr(18),
werks(4),
stlan(1),
END OF ctab.
DATA : BEGIN OF xtab OCCURS 0,
idnrk(18),
menge(13),
postp(1),
END OF xtab.
DATA : BEGIN OF itab OCCURS 0,
matnr(18),
werks(4),
stlan(1),
idnrk(18),
menge(13),
postp(1),
END OF itab.
START-OF-SELECTION.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:/TEST4.TXT'
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = it_rec.
LOOP AT it_rec.
a = strlen( it_rec-rec ).
if a = 55.
itab-matnr = it_rec-rec+0(18).
itab-werks = it_rec-rec+18(4).
itab-stlan = it_rec-rec+22(1).
itab-idnrk = it_rec-rec+23(18).
itab-menge = it_rec-rec+41(13).
itab-postp = it_rec-rec+54(1).
APPEND itab.
elseif a > 55.
itab-matnr = it_rec-rec+0(18).
itab-werks = it_rec-rec+18(4).
itab-stlan = it_rec-rec+22(1).
itab-idnrk = it_rec-rec+23(18).
itab-menge = it_rec-rec+41(13).
itab-postp = it_rec-rec+54(1).
APPEND itab.
itab-idnrk = it_rec-rec+55(18).
itab-menge = it_rec-rec+73(13).
itab-postp = it_rec-rec+86(1).
APPEND itab.
endif.
ENDLOOP.
PERFORM open_group.
LOOP AT itab.
PERFORM bdc_dynpro USING 'SAPLCSDI' '0100'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RC29N-STLAN'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'RC29N-MATNR'
itab-matnr. "'3000000107'.
PERFORM bdc_field USING 'RC29N-WERKS'
itab-werks. "'UN02'.
PERFORM bdc_field USING 'RC29N-STLAN'
itab-stlan. "'1'.
PERFORM bdc_field USING 'RC29N-STLAL'
PERFORM bdc_field USING 'RC29N-DATUV'
'11.08.2008'.
PERFORM bdc_dynpro USING 'SAPLCSDI' '0110'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'RC29K-BMENG'
'1'.
PERFORM bdc_field USING 'RC29K-STLST'
'1'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RC29K-EXSTL'.
PERFORM bdc_dynpro USING 'SAPLCSDI' '0111'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RC29K-LABOR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_dynpro USING 'SAPLCSDI' '0140'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RC29P-POSTP(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'RC29P-IDNRK(01)'
itab-idnrk. "'1000000232'.
PERFORM bdc_field USING 'RC29P-MENGE(01)'
itab-menge. "'100'.
PERFORM bdc_field USING 'RC29P-POSTP(01)'
itab-postp. "'L'.
PERFORM bdc_dynpro USING 'SAPLCSDI' '0130'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RC29P-POSNR'.
PERFORM bdc_field USING 'RC29P-POSNR'
'0010'.
PERFORM bdc_field USING 'RC29P-IDNRK'
'1000000232'.
PERFORM bdc_field USING 'RC29P-MENGE'
'100'.
PERFORM bdc_field USING 'RC29P-MEINS'
'KG'.
PERFORM bdc_dynpro USING 'SAPLCSDI' '0131'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RC29P-POTX1'.
PERFORM bdc_field USING 'RC29P-SANKA'
'X'.
PERFORM bdc_dynpro USING 'SAPLCSDI' '0140'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RC29P-POSNR(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_dynpro USING 'SAPLCSDI' '0140'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RC29P-POSNR(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=FCBU'.
PERFORM bdc_transaction USING 'CS01'.
ENDLOOP.
PERFORM close_group.
Hi
Check this sample code for the Table Control in BDC:
data: fnam(20) type c.
move 1 to id.
loop at TI_STAGING WHERE VENDOR = IT_STAGING-VENDOR AND DOCDATE = IT_STAGING-DOCDATE.
concatenate 'RM06E-EPSTP(0' id ')' into fnam.
perform bdc_field using fnam TI_STAGING-itmcategory.
concatenate 'EKPO-KNTTP(0' id ')' into fnam.
perform bdc_field using fnam TI_STAGING-accassignment.
concatenate 'EKPO-EMATN(0' id ')' into fnam.
perform bdc_field using fnam TI_STAGING-material.
concatenate 'EKPO-TXZ01(0' id ')' into fnam.
perform bdc_field using fnam TI_STAGING-shortxt.
quan = ti_staging-poqty.
concatenate 'EKPO-MENGE(0' id ')' into fnam.
perform bdc_field using fnam quan.
concatenate 'RM06E-EEIND(0' id ')' into fnam.
perform bdc_field using fnam TI_STAGING-deliverydate.
netpr = ti_staging-netpr.
concatenate 'EKPO-NETPR(0' id ')' into fnam.
perform bdc_field using fnam netpr.
concatenate 'EKPO-MATKL(0' id ')' into fnam.
perform bdc_field using fnam TI_STAGING-mategroup.
concatenate 'EKPO-WERKS(0' id ')' into fnam.
perform bdc_field using fnam TI_STAGING-plant.
ID = ID + 1.
ENDLOOP.
Regards,
Vishwa.
Similar Messages
-
Copying data from excel(more than one row) and pasting into table control
I have a requirement to copy data from excel and have it pasted it into the corresponding fields table control when the user clicks on an icon.For the first part I used a class to copy it from the clip board.By the previous process,I get the data inside an internal table, but even after trying to split the data using 'split at cl_abap_char_utilities=>horizontal_tab into table itab.' it's not working.The table and the excel file are of the same structure.
Does anyone know any cause as to why it might not work?Is there any other way to achieve my objective?
BonHi,
try to get data into internal table as below
TYPES : BEGIN OF ty_data ,
zbukr TYPE payr-zbukr ,
hbkid TYPE payr-hbkid ,
hktid TYPE payr-hktid ,
rzawe TYPE payr-rzawe ,
chect TYPE payr-chect ,
laufd TYPE reguh-laufd ,
laufi TYPE reguh-laufi ,
lifnr TYPE reguh-lifnr ,
vblnr TYPE reguh-vblnr ,
rwbtr TYPE reguh-rwbtr , "uncommented
unique_no TYPE char13 , " Added SAP Doc. No. and current year concate in NEFT,RTGS and Fund Transfer cases
END OF ty_data .
DATA : wa_file LIKE LINE OF it_file ,
wa_data TYPE ty_data .
DATA: it_data1 TYPE kcde_intern WITH HEADER LINE,
wa_data1 LIKE LINE OF it_data1.
start-of-selection.
CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
EXPORTING
filename = lv_file1
i_begin_col = '1'
i_begin_row = '4'
i_end_col = '11'
i_end_row = '60000'
TABLES
intern = it_data1
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc = 0.
PERFORM format_data.
ENDIF.
FORM format_data.
DATA : ld_index TYPE i.
FIELD-SYMBOLS : <fs>.
DATA it_tab LIKE wa_data OCCURS 0 WITH HEADER LINE.
LOOP AT it_data1.
MOVE it_data1-col TO ld_index.
ASSIGN COMPONENT ld_index OF STRUCTURE
it_tab TO <fs>.
MOVE : it_data1-value TO <fs>.
MOVE it_data1-value TO p_table.
AT END OF row.
APPEND it_tab.
CLEAR it_tab.
ENDAT.
ENDLOOP.
it_data[] = it_tab[] .
ENDIF.
endform. "format_data -
How to insert more than 12 items using BDC for MB1C
Hi,
When we use LSMW for data transfer of MB1C transaction, more than 12 items can be inserted in a document.
But using BDC only 12 and below is possible, if the flat file system has more that 12 item, then the document is not created.
How to insert more than 12 item in a document.
RegardsHi Gow,
I have uploaded the MB1C through a BDC and it is working fine for n no of items.
Here is the code. May be this will be of your help.
*& Report ZMB1C
report ZMB1C
no standard page heading line-size 255.
type-pools : slis.
tables : t100.
data: begin of record,
MATNR(018),
ERFMG(017),
EXBWR(016),
end of record.
data : itab like table of record with header line.
data : w_bdcdata type bdcdata.
data : t_bdcdata type standard table of bdcdata initial size 1.
data : messtab type standard table of bdcmsgcoll with header line.
data : mstring(300).
data : vf_index type i,
no_lines type i,
count type i value 0.
data : v_bldat(20),
v_budat(20).
*Excel Sheet Data Upload Details
data : vf_start_col type i value '1', "start column
vf_start_row type i value '2', "start row
vf_end_col type i value '100', "maximum column
vf_end_row type i value '10000'. "maximum row
*/ Internal Table For Excel Data
data : it_excel type kcde_cells occurs 0 with header line.
*/ Field symbol
field-symbols : <fs>.
data : begin of it_messtab occurs 0,
plant(10) type c,
status(10) type c,
message(90) type c,
end of it_messtab.
*Data for ALV display
data : wa_fcat type slis_fieldcat_alv,
colcnt type i.
data : it_fieldcat type slis_t_fieldcat_alv,
i_events type slis_t_event.
data : l_title type sychar70.
data : l_repid like sy-repid.
* Selction Screen
selection-screen begin of block b1 with frame title text-000.
parameters : p_file like ibipparms-path obligatory,
p_mode like ctu_params-dismode default 'A'.
selection-screen end of block b1.
selection-screen begin of block b2 with frame title text-001.
parameters : p_bldat like MKPF-BLDAT obligatory,
p_budat like MKPF-BUDAT obligatory,
p_bwart like RM07M-BWARTWA obligatory,
p_werks like RM07M-WERKS obligatory,
p_lgort like RM07M-LGORT obligatory.
selection-screen end of block b2.
* At Selction Screen
at selection-screen on value-request for p_file.
call function 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = ''
IMPORTING
file_name = p_file.
*Start of Selection Event
start-of-selection.
call function 'KCD_EXCEL_OLE_TO_INT_CONVERT'
EXPORTING
filename = p_file
i_begin_col = vf_start_col
i_begin_row = vf_start_row
i_end_col = vf_end_col
i_end_row = vf_end_row
TABLES
intern = it_excel
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
others = 3.
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 it_excel[] is initial.
MESSAGE I000(ZCL_TCSABAP).
else.
sort it_excel by row col.
loop at it_excel.
move : it_excel-col to vf_index.
assign component vf_index of structure itab to <fs>.
move : it_excel-value to <fs>.
at end of row.
append itab.
clear itab.
endat.
endloop.
endif.
if not itab[] is initial.
DESCRIBE TABLE itab LINES no_lines.
clear messtab.
refresh messtab.
CONCATENATE p_bldat+6(2) '.' p_bldat+4(2) '.' p_bldat(4) into v_bldat.
CONCATENATE p_budat+6(2) '.' p_budat+4(2) '.' p_budat(4) into v_budat.
perform map_rec.
call transaction 'MB1C' using t_bdcdata mode p_mode update 'A'
messages into messtab .
clear t_bdcdata.
refresh t_bdcdata.
loop at messtab where msgtyp = 'E' or msgtyp = 'S' .
select single * from t100 where sprsl = messtab-msgspra
and arbgb = messtab-msgid
and msgnr = messtab-msgnr.
if sy-subrc = 0.
mstring = t100-text.
if mstring cs '&1'.
replace '&1' with messtab-msgv1 into mstring.
replace '&2' with messtab-msgv2 into mstring.
replace '&3' with messtab-msgv3 into mstring.
replace '&4' with messtab-msgv4 into mstring.
else.
replace '&' with messtab-msgv1 into mstring.
replace '&' with messtab-msgv2 into mstring.
replace '&' with messtab-msgv3 into mstring.
replace '&' with messtab-msgv4 into mstring.
endif.
condense mstring.
it_messtab-message = mstring(300).
it_messtab-plant = p_werks.
if messtab-msgtyp = 'E'.
it_messtab-status = 'Error'.
else.
it_messtab-status = 'Success'.
endif.
append it_messtab.
clear it_messtab.
endif.
endloop. "messtab
if not it_messtab[] is initial.
perform buildcatalog.
perform display.
endif.
endif.
*& Form Map_Rec
* text
form map_rec.
perform bdc_dynpro using 'SAPMM07M' '0400'.
perform bdc_field using 'BDC_CURSOR'
'RM07M-WVERS3'.
perform bdc_field using 'BDC_OKCODE'
'NPE'.
perform bdc_field using 'MKPF-BLDAT'
v_bldat.
perform bdc_field using 'MKPF-BUDAT'
v_budat.
perform bdc_field using 'RM07M-BWARTWA'
p_bwart.
perform bdc_field using 'RM07M-WERKS'
p_werks.
perform bdc_field using 'RM07M-LGORT'
p_lgort.
perform bdc_field using 'XFULL'
perform bdc_field using 'RM07M-XNAPR'
'X'.
perform bdc_field using 'RM07M-WVERS2'
perform bdc_field using 'RM07M-WVERS3'
'X'.
loop at itab.
count = count + 1.
perform bdc_dynpro using 'SAPMM07M' '0410'.
perform bdc_field using 'BDC_CURSOR'
'MSEG-EXBWR'.
if count <> no_lines.
perform bdc_field using 'BDC_OKCODE'
'=NPE'.
elseif count = no_lines.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
endif.
perform bdc_field using 'MSEG-MATNR'
itab-MATNR.
perform bdc_field using 'MSEG-ERFMG'
itab-ERFMG.
perform bdc_field using 'MSEG-EXBWR'
itab-EXBWR.
endloop. "itab
endform. "Map_Rec
** Form BDC_DYNPRO
form bdc_dynpro using program dynpro.
clear w_bdcdata.
w_bdcdata-program = program.
w_bdcdata-dynpro = dynpro.
w_bdcdata-dynbegin = 'X'.
append w_bdcdata to t_bdcdata.
endform. "bdc_dynpro
** Form BDC_FIELD
form bdc_field using fnam fval.
if fval <> space.
clear w_bdcdata.
w_bdcdata-fnam = fnam.
w_bdcdata-fval = fval.
append w_bdcdata to t_bdcdata.
else.
clear w_bdcdata.
w_bdcdata-fnam = fnam.
w_bdcdata-fval = fval.
append w_bdcdata to t_bdcdata.
endif.
endform. "bdc_field
* FORM buildcatalog *
form buildcatalog.
clear wa_fcat.
clear it_fieldcat.
colcnt = colcnt + 1.
wa_fcat-col_pos = colcnt.
wa_fcat-fieldname = 'PLANT'.
wa_fcat-tabname = it_messtab.
wa_fcat-seltext_l = 'PLANT'.
wa_fcat-key = 'X'.
wa_fcat-outputlen = '10'.
append wa_fcat to it_fieldcat.
clear wa_fcat.
colcnt = colcnt + 1.
wa_fcat-col_pos = colcnt.
wa_fcat-fieldname = 'STATUS'.
wa_fcat-tabname = it_messtab.
wa_fcat-seltext_l = 'STATUS'.
wa_fcat-outputlen = '10'.
append wa_fcat to it_fieldcat.
clear wa_fcat.
colcnt = colcnt + 1.
wa_fcat-col_pos = colcnt.
wa_fcat-fieldname = 'MESSAGE'.
wa_fcat-tabname = it_messtab.
wa_fcat-seltext_l = 'Message'.
wa_fcat-outputlen = '90'.
append wa_fcat to it_fieldcat.
endform. "buildcatalog
* FORM display *
form display.
l_title = text-002.
l_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = l_repid
i_grid_title = l_title
it_fieldcat = it_fieldcat
it_events = i_events[]
TABLES
t_outtab = it_messtab
EXCEPTIONS
program_error = 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.
endform. "display
Regards,
Amit -
Line items missing in RFC table when they are more than one!!!
Hi All,
I am doing a scenario where i map a proxy from SCM to a RFC in R/3.
The problem i am facing is my proxy has more than 1 line item for a purchase order but in R/3 the RFC table contains only the first line item.
Is there any special mapping that i need to do to capture multiple line items in a PO.
Regards,
Jayaram.MHi,
When you do the mapping, test it with the payload and see whether you are able to generate multiple line items in the target.
Next check how you are passing it to the RFC, whether as a single line item or as a table.
If in the mapping you were not able to see the multiple line items, check your context changes accordingly.
Accordingly you can check.
Regards
Krish -
How to upload a file which has more than 999 line item through BDC ?
Hello Techards
Hi to all
Can any body tell me how to upload a file which has more than 999 line item through BDC for traction F-02 ?
Thanks in advance.
ShovanHello Shovan,
You split it up to post two accounting documents with the help of a "suspense" a/c.
Say, you have to post the following line items below:
line 1 - dr. - GL a/c X - $1000
line 2 - cr. - GL a/c Y - $1
line 3 - cr. - GL a/c Y - $1
line 1001 - cr. - GL a/c Y - $1
You cannot post the above as a single doc in SAP (because of technical reasons), so you need to break it up into 2 documents as below:
Doc1
line 1 - dr - GL a/c X - $1000
line 2 - cr - GL a/c Y - $1
line 3 - cr - GL a/c Y - $1
line 998 - cr - GL a/c Y - $1
line 999 - cr - SUSPENSE a/c - $3
Doc2
line 1 - dr - SUSPENSE a/c - $3
line 2 - cr - GL a/c Y - $3
Note that there is no incorrect impact on accounting as first we credit suspense a/c by $3 and next we debit the same suspense a/c by $3 as a result the effect is nil. Similarly, we credit $997 to GL a/c Y (which is less by $3) in the first doc which is compensated by the second doc by crediting the shortfall of $3.
Hope this helps,
Cheers,
Sougata. -
Is it possible to place more than one Item on same line on the FORM
Can we placed more than one Item on the form?
for ex: I want to use TextFields to input the Date of birth in form of DD/MM/YY
I want to put on the form like
Enter DOB :- DD MM YYYY
Please suggest if it is possible any way in J2MEIt will depend on the phone. There is no way of knowing if the items actually will be on the same line or not. On a phone with a small screen, the items are likely to end up on two lines.
You can however make sure that the lines will occupy two lines by using the setLayout(int layout) method which belongs to the Item class. -
Entering more than one item using bapi_salesorder_createfromdat1
Hi,
I am connecting a CRM system with SAP, I have got the xml file for Sales Order with all the data's and i want to create a sales order in sap system using bapi_salesorder_createfromdat1.
My question is I am able to enter one item to the sap sales order. for inputing more than on items what should i do. Please help me.
thanksHi,
Then there must be some problem with the appending of the data in the ITEM table.
just see in the debugging.
Regards,
Atish -
How to insert multiple line items in fv60 using bdc.
Hi all,
How to insert multiple line items in fv60 using bdcshi
chk this
DATA : IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
DATA : IT_MESSAGES LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
DATA : V_EBELP(30) , V_MENGE(30) , V_WERKS(30), V_EMATN(30) ,
V_PEINH(30).
DATA : FILE TYPE STRING, V_MSG(100) , V_IND(2) TYPE N , FLAG VALUE 'X'.
PARAMETERS: P_FILE(50) TYPE C DEFAULT 'C:\ME21_TEST'.
DATA : BEGIN OF ITAB OCCURS 0,
IND(02),
LIFNR_001(010),
data element: BSART
BSART_002(004),
data element: BEDAT
data element: EKORG
EKORG_004(004),
EKGRP_006(003),
data element: LPEIN
LPEIN_005(001),
data element: EMATNR
EMATN_01_007(018),
data element: EWERK
WERKS_01_008(004),
data element: EPEIN
PEINH_01_009(006),
data element: EWERK
MENGE_01_013(017),
data element: AUFEP
EBELP_014(005),
data element: AUFEP
END OF ITAB.
START-OF-SELECTION.
FILE = P_FILE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = FILE
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
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.
SORT ITAB BY IND.
START-OF-SELECTION.
LOOP AT ITAB.
REFRESH IT_MESSAGES.
<b>V_IND = V_IND + 1.</b>
<b>AT NEW IND.</b>
<b>READ TABLE ITAB INDEX SY-TABIX.</b>
PERFORM BDC_DYNPRO USING 'SAPMM06E' '0100'.
PERFORM BDC_FIELD USING 'EKKO-LIFNR'
ITAB-LIFNR_001.
PERFORM BDC_FIELD USING 'RM06E-BSART'
ITAB-BSART_002.
*perform bdc_field using 'RM06E-BEDAT'
ITAB-BEDAT_003.
PERFORM BDC_FIELD USING 'EKKO-EKORG'
ITAB-EKORG_004.
PERFORM BDC_FIELD USING 'RM06E-LPEIN'
ITAB-LPEIN_005.
PERFORM BDC_FIELD USING 'EKKO-EKGRP'
ITAB-EKGRP_006.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
ENDAT.
<b>PERFORM BDC_DYNPRO USING 'SAPMM06E' '0120'.
CONCATENATE 'EKPO-EMATN(' V_IND ')' INTO V_EMATN.
PERFORM BDC_FIELD USING V_EMATN
ITAB-EMATN_01_007.
CONCATENATE 'EKPO-WERKS(' V_IND ')' INTO V_WERKS.
PERFORM BDC_FIELD USING V_WERKS
ITAB-WERKS_01_008.
CONCATENATE 'EKPO-PEINH(' V_IND ')' INTO V_PEINH.
PERFORM BDC_DYNPRO USING 'SAPMM06E' '0120'.
PERFORM BDC_FIELD USING V_PEINH
ITAB-PEINH_01_009.
*CONCATENATE 'EKPO-MENGE(' V_IND ')' INTO V_MENGE.
*perform bdc_dynpro using 'SAPMM06E' '0120'.
*perform bdc_field using V_MENGE
ITAB-MENGE_01_013.
*CONCATENATE 'EKPO-EBELP(' V_IND ')' INTO V_EBELP.
PERFORM BDC_DYNPRO USING 'SAPMM06E' '0120'.
PERFORM BDC_FIELD USING 'RM06E-EBELP'
ITAB-EBELP_014.</b>PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
AT END OF IND.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=BU'.
ENDAT.
CALL TRANSACTION 'ME21' USING IT_BDCDATA MODE 'A'
UPDATE 'S'
MESSAGES INTO IT_MESSAGES.
LOOP AT IT_MESSAGES WHERE MSGTYP = 'E' OR MSGTYP = 'A'.
IF FLAG = 'X'.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
DEST = FILLER8
GROUP = 'GAMY_FAILURE'
HOLDDATE = FILLER8
KEEP = 'X'
USER = SY-UNAME
RECORD = FILLER1
PROG = SY-CPROG
IMPORTING
QID =
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 <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CLEAR FLAG.
ENDIF.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'ME21'
POST_LOCAL = NOVBLOCAL
PRINTING = NOPRINT
SIMUBATCH = ' '
CTUPARAMS = ' '
TABLES
DYNPROTAB = IT_BDCDATA
EXCEPTIONS
INTERNAL_ERROR = 1
NOT_OPEN = 2
QUEUE_ERROR = 3
TCODE_INVALID = 4
PRINTING_INVALID = 5
POSTING_INVALID = 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.
ENDIF.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = IT_MESSAGES-MSGID
LANG = 'EN'
NO = IT_MESSAGES-MSGNR
V1 = IT_MESSAGES-MSGV1
V2 = IT_MESSAGES-MSGV2
V3 = IT_MESSAGES-MSGV3
V4 = IT_MESSAGES-MSGV4
IMPORTING
MSG = V_MSG
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2
WRITE : / V_MSG.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDLOOP.
ENDLOOP.
IF FLAG NE 'X'.
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
Start new screen *
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.
Insert field *
FORM BDC_FIELD USING FNAM FVAL.
CLEAR IT_BDCDATA.
IT_BDCDATA-FNAM = FNAM.
IT_BDCDATA-FVAL = FVAL.
APPEND IT_BDCDATA. -
More than one item table in HIERSEQ_LIST_DISPLAY
Hi ,
Is it possible to have moe than one item table in HIERSEQ_LIST_DISPLAY.
if we have more than one item table with different structures then what is the best way to disply them.
Thanks and Regards,thank you
-
How to use table control in bdc, plz somebody tell me.
Hi Gurus,
Ples tell me
how to use table control in bdc, plz somebody tell me.
And send Sample CODE also. Thnaks in advance.hi,
Table control / step loop in BDC
Steploop and table contol 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')
we can determine the number of visible lines on Transaction Screen from our Calling BDC program.
Demo ABAP code has two purposes:
1. how to determine number of visible lines and how to calculte page number;
(the 'calpage' routine has been modify to meet general purpose usage)
2. using field symbol in BDC program, please pay special attention to the difference
in Static ASSIGN and Dynamic ASSIGN.
Step1: 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)
Step2: 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)
Step3: write a subroutine calcalculating number of pages
(here, the name of actual parameter is the same as formal parameter)
global data: 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.
Step4 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.
Step5 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.
Step6
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: , , .
data: name1(14) value 'EKPO-EMATN(XX)',
name2(14) value 'EKPO-MENGE(XX)',
name3(15) value 'RM06E-SELKZ(XX)'.
assign: name1 to ,
name2 to ,
name3 to .
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 DataTable-matnr.
perform bdcfield using DataTable-menge.
perform bdcfield using DataTable-indicator.
endloop.
enddo.
example 1
BDC table control is an area on the screen in which you can display data in tabular form. You process it using a loop. Table controls are comparable to step loop tables. While a table control consists of a single definition row, step loop blocks may extend over more than one row. Table controls are more flexible than step loops, and are intended to replace them
When you need to handle a scenario like in sales order,it may contain more than one material,if you have more than one material We have to use table control,it will have number of columns and number of rows.
Table controls allow you to enter, display, and modify tabular data easily on the screen
Check this code,
PARAMETERS: file1 LIKE rlgrap-filename.
*Internal Table Declarations
DATA: BEGIN OF itab OCCURS 0,
matnr(18) TYPE c, "MaterialNumber
werks(4) TYPE c, "Plant
vdatu(10) TYPE c, "Valid From Date
bdatu(10) TYPE c, "Valid To Date
lifnr(10) TYPE c, "Vendor Number
ekorg(4) TYPE c, "Purchasing Organization
feskz TYPE c, "Fixed
autet TYPE c, "MRP Indicator
END OF itab.
DATA: bdcdata LIKE TABLE OF bdcdata WITH HEADER LINE.
*VARIABLES Declarations
DATA: wa1 LIKE LINE OF itab. "Workarea for ITAB
DATA: n TYPE i, "Check
count TYPE i.
DATA: cnt(2), "Counter
wa(15). "Workarea to hold concatenatedvalue
DATA v_msg(100).
DATA: flag.
DATA: file TYPE string.
*Initialization event
INITIALIZATION.
*At-selection-screen event
*To provide Input help for file name
AT SELECTION-SCREEN ON VALUE-REQUEST FOR file1.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
IMPORTING
file_name = file1.
*START-OF-SELECTION EVENT
START-OF-SELECTION.
MOVE file1 TO file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = file
filetype = 'ASC'
has_field_separator = 'X'
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.
*To populate BDCDATA and start data transfer
LOOP AT itab .
To validate Plant range
IF itab-werks = '1000' OR itab-werks = '2000'
OR itab-werks = '1008'.
AT NEW werks.
CLEAR: n.
cnt = 1.
PERFORM bdc_dynpro USING 'SAPLMEOR' '0200'.
PERFORM bdc_field USING 'BDC_CURSOR'
'EORD-MATNR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'EORD-MATNR'
itab-matnr.
PERFORM bdc_field USING 'EORD-WERKS'
itab-werks.
PERFORM bdc_dynpro USING 'SAPLMEOR' '0205'.
CONCATENATE 'EORD-EKORG(' cnt ')' INTO wa.
PERFORM bdc_field USING 'BDC_CURSOR'
wa.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BU'.
ENDAT.
IF n = 12.
READ TABLE bdcdata WITH KEY fval = '=BU'.
bdcdata-fval = '=NS'.
MODIFY bdcdata INDEX sy-tabix TRANSPORTING fval.
PERFORM bdc_dynpro USING 'SAPLMEOR' '0205'.
PERFORM bdc_field USING 'BDC_CURSOR'
'EORD-VDATU(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BU'.
cnt = 2.
n = 2.
ENDIF.
CONCATENATE 'EORD-VDATU(' cnt ')' INTO wa.
PERFORM bdc_field USING wa
itab-vdatu.
CONCATENATE 'EORD-BDATU(' cnt ')' INTO wa.
PERFORM bdc_field USING wa
itab-bdatu.
CONCATENATE 'EORD-LIFNR(' cnt ')' INTO wa.
PERFORM bdc_field USING wa
itab-lifnr.
CONCATENATE 'EORD-EKORG(' cnt ')' INTO wa.
PERFORM bdc_field USING wa
itab-ekorg.
CONCATENATE 'RM06W-FESKZ(' cnt ')' INTO wa.
PERFORM bdc_field USING wa
itab-feskz.
CONCATENATE 'EORD-AUTET(' cnt ')' INTO wa.
PERFORM bdc_field USING wa
itab-autet.
IF n <> 12.
n = cnt.
ENDIF.
cnt = cnt + 1.
AT END OF werks.
CALL TRANSACTION 'ME01' USING bdcdata
UPDATE 'S'
MODE 'A'.
CLEAR:bdcdata,bdcdata[].
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = sy-msgid
lang = 'EN'
no = sy-msgno
v1 = sy-msgv1
v2 = sy-msgv2
v3 = sy-msgv3
v4 = sy-msgv4
IMPORTING
msg = v_msg.
WRITE:/ v_msg.
CLEAR: bdcdata,bdcdata[],flag.
ENDAT.
ENDIF.
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 values
FORM bdc_field USING fnam fval.
IF NOT fval IS INITIAL.
CLEAR bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
APPEND bdcdata.
ENDIF.
CLEAR wa.
ENDFORM.
Sample code 2
THis is example to upload the Bank details of the Vendor which has the TC.
REPORT zprataptable2
NO STANDARD PAGE HEADING LINE-SIZE 255.
DATA : BEGIN OF itab OCCURS 0,
i1 TYPE i,
lifnr LIKE rf02k-lifnr,
bukrs LIKE rf02k-bukrs,
ekorg LIKE rf02k-ekorg,
ktokk LIKE rf02k-ktokk,
anred LIKE lfa1-anred,
name1 LIKE lfa1-name1,
sortl LIKE lfa1-sortl,
land1 LIKE lfa1-land1,
akont LIKE lfb1-akont,
fdgrv LIKE lfb1-fdgrv,
waers LIKE lfm1-waers,
END OF itab.
DATA : BEGIN OF jtab OCCURS 0,
j1 TYPE i,
banks LIKE lfbk-banks,
bankl LIKE lfbk-bankl,
bankn LIKE lfbk-bankn,
END OF jtab.
DATA : cnt(4) TYPE n.
DATA : fdt(20) TYPE c.
DATA : c TYPE i.
INCLUDE bdcrecx1.
START-OF-SELECTION.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
filename = 'C:\first1.txt'
filetype = 'DAT'
TABLES
data_tab = itab.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
filename = 'C:\second.txt'
filetype = 'DAT'
TABLES
data_tab = jtab.
LOOP AT itab.
PERFORM bdc_dynpro USING 'SAPMF02K' '0100'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF02K-KTOKK'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'RF02K-LIFNR'
itab-lifnr.
PERFORM bdc_field USING 'RF02K-BUKRS'
itab-bukrs.
PERFORM bdc_field USING 'RF02K-EKORG'
itab-ekorg.
PERFORM bdc_field USING 'RF02K-KTOKK'
itab-ktokk.
PERFORM bdc_dynpro USING 'SAPMF02K' '0110'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFA1-LAND1'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'LFA1-ANRED'
itab-anred.
PERFORM bdc_field USING 'LFA1-NAME1'
itab-name1.
PERFORM bdc_field USING 'LFA1-SORTL'
itab-sortl.
PERFORM bdc_field USING 'LFA1-LAND1'
itab-land1.
PERFORM bdc_dynpro USING 'SAPMF02K' '0120'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFA1-KUNNR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFBK-BANKN(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
cnt = 0.
LOOP AT jtab WHERE j1 = itab-i1.
cnt = cnt + 1.
CONCATENATE 'LFBK-BANKS(' cnt ')' INTO fdt.
PERFORM bdc_field USING fdt jtab-banks.
CONCATENATE 'LFBK-BANKL(' cnt ')' INTO fdt.
PERFORM bdc_field USING fdt jtab-bankl.
CONCATENATE 'LFBK-BANKN(' cnt ')' INTO fdt.
PERFORM bdc_field USING fdt jtab-bankn.
IF cnt = 5.
cnt = 0.
PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFBK-BANKS(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=P+'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFBK-BANKN(02)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
ENDIF.
ENDLOOP.
PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFBK-BANKS(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0210'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFB1-FDGRV'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'LFB1-AKONT'
itab-akont.
PERFORM bdc_field USING 'LFB1-FDGRV'
itab-fdgrv.
PERFORM bdc_dynpro USING 'SAPMF02K' '0215'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFB1-ZTERM'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0220'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFB5-MAHNA'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0310'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFM1-WAERS'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'LFM1-WAERS'
itab-waers.
PERFORM bdc_dynpro USING 'SAPMF02K' '0320'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF02K-LIFNR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
PERFORM bdc_dynpro USING 'SAPLSPO1' '0300'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=YES'.
PERFORM bdc_transaction USING 'XK01'.
ENDLOOP.
PERFORM close_group.
Header file:
1 63190 0001 0001 0001 mr bal188 b in 31000 a1 inr
2 63191 0001 0001 0001 mr bal189 b in 31000 a1 inr
TC file:
1 in sb 11000
1 in sb 12000
1 in sb 13000
1 in sb 14000
1 in sb 15000
1 in sb 16000
1 in sb 17000
1 in sb 18000
1 in sb 19000
1 in sb 20000
1 in sb 21000
1 in sb 22000
2 in sb 21000
2 in sb 22000
Regards -
Error Handling in table control for line item.
Hi,
Please how to do error handling in table control for line item in bdc,i have used format_message for header but i don't no fill decamps internal tabled and how to do background processing in call transaction.
ThanksBackground processing is not possible using call transaction method.
You can create an executable program which can have CALL TRANSACTION BDC code. And this can be run in background.
What do you exactly mean by Error handling for Items in table control. Can you give some more details. -
Can't add a goods-issue with more than one item and one is serial managed.
Hi,
We are trying to issue more than one item to a production order using the DI API. If none of the items is serial managed, they all are accepted and the goods-issue Add is successful. If one the items is batch-managed, the goods-issue Add is also successful. I am able to add the goods-receipt if I it contains only one item and it is serial-number managed. However, if Im issuing more than one item and one or more of the items is serial number managed, then the DI API will not add the goods-issue. The error message that appears refers to an item that is not among the items being issued. The message is:
-10: (IGE1.WhsCode)(line: 3), Item A00006 with system serial 1 is not in stock.
Again item A00006 is not even in the group of items being issued.
The code I am using for the serial number part is:
With oGoodsIssue.Lines.SerialNumbers
.SystemSerialNumber = rs.Fields.Item("SysSerial").Value
.ManufacturerSerialNumber = rs.Fields.Item("MfrSN").Value
.InternalSerialNumber = rs.Fields.Item("IntrSerial").Value
.SetCurrentLine(n)
.Add()
rs.MoveNext()
n += 1
End With
The rs is a recordset that the code is looping through as the serial numbers are being added.
The error message does not occur during this code. It occurs when it tries to add the full goods-receipt. Does anyone have any idea how I can fix this?
Thanks,
Mike
Edited by: Mike Angelastro on Mar 31, 2008 8:43 AMHi Mike,
Try to do the ".Add" only if you need it. Doing a ".add" without assignation may cause the error you have.
I guess your n variable start at 1 or 0, so you could put code like this :
With oGoodsIssue.Lines.SerialNumbers
if n = 0 then (or 1, also I don't the correct syntax of your programming language)
.Add()
end if
.SystemSerialNumber = rs.Fields.Item("SysSerial").Value
.ManufacturerSerialNumber = rs.Fields.Item("MfrSN").Value
.InternalSerialNumber = rs.Fields.Item("IntrSerial").Value
.SetCurrentLine(n)
rs.MoveNext()
n += 1
End With
HTH
Jodérick -
How can we use TABLE CONTROL in BDC and WORK FLOW of ABAP.
how can we use TABLE CONTROL in BDC and WORK FLOW of ABAP.?
please explain the important questions.How to deal with table control / step loop in BDC
Steploop and table contol 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 ABAP code has two purposes:
1. how to determine number of visible lines and how to calculte page number;
(the 'calpage' routine has been modify to meet general purpose usage)
2. 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..)
Step1: 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)
Step2: 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)
Step3: write a subroutine calcalculating number of pages
(here, the name of actual parameter is the same as formal parameter)
global data: 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.
Step4 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.
Step5 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.
Step6 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.
An example abap program of handling Table Control during bdc programming.
REPORT zmm_bdcp_purchaseorderkb02
NO STANDARD PAGE HEADING LINE-SIZE 255.
Declaring internal tables *
*-----Declaring line structure
DATA : BEGIN OF it_dummy OCCURS 0,
dummy(255) TYPE c,
END OF it_dummy.
*-----Internal table for line items
DATA : BEGIN OF it_idata OCCURS 0,
ematn(18), "Material Number.
menge(13), "Qyantity.
netpr(11), "Net Price.
werks(4), "Plant.
ebelp(5), "Item Number.
END OF it_idata.
*-----Deep structure for header data and line items
DATA : BEGIN OF it_me21 OCCURS 0,
lifnr(10), "Vendor A/c No.
bsart(4), "A/c Type.
bedat(8), "Date of creation of PO.
ekorg(4), "Purchasing Organisation.
ekgrp(3), "Purchasing Group.
x_data LIKE TABLE OF it_idata,
END OF it_me21.
DATA : x_idata LIKE LINE OF it_idata.
DATA : v_delimit VALUE ','.
DATA : v_indx(3) TYPE n.
DATA : v_fnam(30) TYPE c.
DATA : v_count TYPE n.
DATA : v_ne TYPE i.
DATA : v_ns TYPE i.
*include bdcrecx1.
INCLUDE zmm_incl_purchaseorderkb01.
Search help for file *
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
IMPORTING
file_name = p_file.
START-OF-SELECTION.
To upload the data into line structure *
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
filename = p_file
filetype = 'DAT'
TABLES
data_tab = it_dummy.
Processing the data from line structure to internal tables *
REFRESH:it_me21.
CLEAR :it_me21.
LOOP AT it_dummy.
IF it_dummy-dummy+0(01) = 'H'.
v_indx = v_indx + 1.
CLEAR it_idata.
REFRESH it_idata.
CLEAR it_me21-x_data.
REFRESH it_me21-x_data.
SHIFT it_dummy.
SPLIT it_dummy AT v_delimit INTO it_me21-lifnr
it_me21-bsart
it_me21-bedat
it_me21-ekorg
it_me21-ekgrp.
APPEND it_me21.
ELSEIF it_dummy-dummy+0(01) = 'L'.
SHIFT it_dummy.
SPLIT it_dummy AT v_delimit INTO it_idata-ematn
it_idata-menge
it_idata-netpr
it_idata-werks
it_idata-ebelp.
APPEND it_idata TO it_me21-x_data.
MODIFY it_me21 INDEX v_indx.
ENDIF.
ENDLOOP.
To open the group *
PERFORM open_group.
To populate the bdcdata table for header data *
LOOP AT it_me21.
v_count = v_count + 1.
REFRESH it_bdcdata.
PERFORM subr_bdc_table USING: 'X' 'SAPMM06E' '0100',
' ' 'BDC_CURSOR' 'EKKO-LIFNR',
' ' 'BDC_OKCODE' '/00',
' ' 'EKKO-LIFNR' it_me21-lifnr,
' ' 'RM06E-BSART' it_me21-bsart,
' ' 'RM06E-BEDAT' it_me21-bedat,
' ' 'EKKO-EKORG' it_me21-ekorg,
' ' 'EKKO-EKGRP' it_me21-ekgrp,
' ' 'RM06E-LPEIN' 'T'.
PERFORM subr_bdc_table USING: 'X' 'SAPMM06E' '0120',
' ' 'BDC_CURSOR' 'RM06E-EBELP',
' ' 'BDC_OKCODE' '/00'.
MOVE 1 TO v_indx.
*-----To populate the bdcdata table for line item data
LOOP AT it_me21-x_data INTO x_idata.
CONCATENATE 'EKPO-EMATN(' v_indx ')' INTO v_fnam.
PERFORM subr_bdc_table USING ' ' v_fnam x_idata-ematn.
CONCATENATE 'EKPO-MENGE(' v_indx ')' INTO v_fnam.
PERFORM subr_bdc_table USING ' ' v_fnam x_idata-menge.
CONCATENATE 'EKPO-NETPR(' v_indx ')' INTO v_fnam.
PERFORM subr_bdc_table USING ' ' v_fnam x_idata-netpr.
CONCATENATE 'EKPO-WERKS(' v_indx ')' INTO v_fnam.
PERFORM subr_bdc_table USING ' ' v_fnam x_idata-werks.
v_indx = v_indx + 1.
PERFORM subr_bdc_table USING: 'X' 'SAPMM06E' '0120',
' ' 'BDC_CURSOR' 'RM06E-EBELP',
' ' 'BDC_OKCODE' '/00'.
ENDLOOP.
PERFORM subr_bdc_table USING: 'X' 'SAPMM06E' '0120',
' ' 'BDC_CURSOR' 'RM06E-EBELP',
' ' 'BDC_OKCODE' '=BU'.
PERFORM bdc_transaction USING 'ME21'.
ENDLOOP.
PERFORM close_group.
End of selection event *
END-OF-SELECTION.
IF session NE 'X'.
*-----To display the successful records
WRITE :/10 text-001. "Sucess records
WRITE :/10 SY-ULINE(20).
SKIP.
IF it_sucess IS INITIAL.
WRITE :/ text-002.
ELSE.
WRITE :/ text-008, "Total number of Succesful records
35 v_ns.
SKIP.
WRITE:/ text-003, "Vendor Number
17 text-004, "Record number
30 text-005. "Message
ENDIF.
LOOP AT it_sucess.
WRITE:/4 it_sucess-lifnr,
17 it_sucess-tabix CENTERED,
30 it_sucess-sucess_rec.
ENDLOOP.
SKIP.
*-----To display the erroneous records
WRITE:/10 text-006. "Error Records
WRITE:/10 SY-ULINE(17).
SKIP.
IF it_error IS INITIAL.
WRITE:/ text-007. "No error records
ELSE.
WRITE:/ text-009, "Total number of erroneous records
35 v_ne.
SKIP.
WRITE:/ text-003, "Vendor Number
17 text-004, "Record number
30 text-005. "Message
ENDIF.
LOOP AT it_error.
WRITE:/4 it_error-lifnr,
17 it_error-tabix CENTERED,
30 it_error-error_rec.
ENDLOOP.
REFRESH it_sucess.
REFRESH it_error.
ENDIF.
CODE IN INCLUDE.
Include ZMM_INCL_PURCHASEORDERKB01
DATA: it_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
DATA: it_MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
DATA: E_GROUP_OPENED.
*-----Internal table to store sucess records
DATA:BEGIN OF it_sucess OCCURS 0,
msgtyp(1) TYPE c,
lifnr LIKE ekko-lifnr,
tabix LIKE sy-tabix,
sucess_rec(125),
END OF it_sucess.
DATA: g_mess(125) type c.
*-----Internal table to store error records
DATA:BEGIN OF it_error OCCURS 0,
msgtyp(1) TYPE c,
lifnr LIKE ekko-lifnr,
tabix LIKE sy-tabix,
error_rec(125),
END OF it_error.
Selection screen
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS session RADIOBUTTON GROUP ctu. "create session
SELECTION-SCREEN COMMENT 3(20) text-s07 FOR FIELD session.
SELECTION-SCREEN POSITION 45.
PARAMETERS ctu RADIOBUTTON GROUP ctu. "call transaction
SELECTION-SCREEN COMMENT 48(20) text-s08 FOR FIELD ctu.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 3(20) text-s01 FOR FIELD group.
SELECTION-SCREEN POSITION 25.
PARAMETERS group(12). "group name of session
SELECTION-SCREEN COMMENT 48(20) text-s05 FOR FIELD ctumode.
SELECTION-SCREEN POSITION 70.
PARAMETERS ctumode LIKE ctu_params-dismode DEFAULT 'N'.
"A: show all dynpros
"E: show dynpro on error only
"N: do not display dynpro
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 48(20) text-s06 FOR FIELD cupdate.
SELECTION-SCREEN POSITION 70.
PARAMETERS cupdate LIKE ctu_params-updmode DEFAULT 'L'.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 3(20) text-s03 FOR FIELD keep.
SELECTION-SCREEN POSITION 25.
PARAMETERS: keep AS CHECKBOX. "' ' = delete session if finished
"'X' = keep session if finished
SELECTION-SCREEN COMMENT 48(20) text-s09 FOR FIELD e_group.
SELECTION-SCREEN POSITION 70.
PARAMETERS e_group(12). "group name of error-session
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 51(17) text-s03 FOR FIELD e_keep.
SELECTION-SCREEN POSITION 70.
PARAMETERS: e_keep AS CHECKBOX. "' ' = delete session if finished
"'X' = keep session if finished
SELECTION-SCREEN END OF LINE.
PARAMETERS:p_file LIKE rlgrap-filename.
at selection screen *
AT SELECTION-SCREEN.
group and user must be filled for create session
IF SESSION = 'X' AND
GROUP = SPACE. "OR USER = SPACE.
MESSAGE E613(MS).
ENDIF.
create batchinput session *
FORM OPEN_GROUP.
IF SESSION = 'X'.
SKIP.
WRITE: /(20) 'Create group'(I01), GROUP.
SKIP.
*----open batchinput group
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = GROUP
USER = sy-uname.
WRITE:/(30) 'BDC_OPEN_GROUP'(I02),
(12) 'returncode:'(I05),
SY-SUBRC.
ENDIF.
ENDFORM. "OPEN_GROUP
end batchinput session *
FORM CLOSE_GROUP.
IF SESSION = 'X'.
*------close batchinput group
CALL FUNCTION 'BDC_CLOSE_GROUP'.
WRITE: /(30) 'BDC_CLOSE_GROUP'(I04),
(12) 'returncode:'(I05),
SY-SUBRC.
ELSE.
IF E_GROUP_OPENED = 'X'.
CALL FUNCTION 'BDC_CLOSE_GROUP'.
WRITE: /.
WRITE: /(30) 'Fehlermappe wurde erzeugt'(I06).
ENDIF.
ENDIF.
ENDFORM. "CLOSE_GROUP
Start new transaction according to parameters *
FORM BDC_TRANSACTION USING TCODE TYPE ANY.
DATA: L_SUBRC LIKE SY-SUBRC.
*------batch input session
IF SESSION = 'X'.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = TCODE
TABLES
DYNPROTAB = it_BDCDATA.
WRITE: / 'BDC_INSERT'(I03),
TCODE,
'returncode:'(I05),
SY-SUBRC,
'RECORD:',
SY-INDEX.
ELSE.
REFRESH it_MESSTAB.
CALL TRANSACTION TCODE USING it_BDCDATA
MODE CTUMODE
UPDATE CUPDATE
MESSAGES INTO it_MESSTAB.
L_SUBRC = SY-SUBRC.
WRITE: / 'CALL_TRANSACTION',
TCODE,
'returncode:'(I05),
L_SUBRC,
'RECORD:',
SY-INDEX.
ENDIF.
Message handling for Call Transaction *
perform subr_mess_hand using g_mess.
*-----Erzeugen fehlermappe
IF L_SUBRC <> 0 AND E_GROUP <> SPACE.
IF E_GROUP_OPENED = ' '.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = E_GROUP
USER = sy-uname
KEEP = E_KEEP.
E_GROUP_OPENED = 'X'.
ENDIF.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = TCODE
TABLES
DYNPROTAB = it_BDCDATA.
ENDIF.
REFRESH it_BDCDATA.
ENDFORM. "BDC_TRANSACTION
Form subr_bdc_table *
text
-->P_0220 text *
-->P_0221 text *
-->P_0222 text *
FORM subr_bdc_table USING VALUE(P_0220) TYPE ANY
VALUE(P_0221) TYPE ANY
VALUE(P_0222) TYPE ANY.
CLEAR it_bdcdata.
IF P_0220 = ' '.
CLEAR it_bdcdata.
it_bdcdata-fnam = P_0221.
it_bdcdata-fval = P_0222.
APPEND it_bdcdata.
ELSE.
it_bdcdata-dynbegin = P_0220.
it_bdcdata-program = P_0221.
it_bdcdata-dynpro = P_0222.
APPEND it_bdcdata.
ENDIF.
ENDFORM. " subr_bdc_table
Form subr_mess_hand *
text *
-->P_G_MESS text *
FORM subr_mess_hand USING P_G_MESS TYPE ANY.
LOOP AT IT_MESSTAB.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = it_messtab-msgid
LANG = it_messtab-msgspra
NO = it_messtab-msgnr
v1 = it_messtab-msgv1
v2 = it_messtab-msgv2
IMPORTING
MSG = P_G_MESS
EXCEPTIONS
OTHERS = 0.
CASE it_messtab-msgtyp.
when 'E'.
it_error-error_rec = P_G_MESS.
it_error-lifnr = it_me21-lifnr.
it_error-tabix = v_count.
APPEND IT_ERROR.
when 'S'.
it_sucess-sucess_rec = P_G_MESS.
it_sucess-lifnr = it_me21-lifnr.
it_sucess-tabix = v_count.
APPEND IT_SUCESS.
endcase.
ENDLOOP.
Describe table it_sucess lines v_ns.
Describe table it_error lines v_ne.
ENDFORM. " subr_mess_hand
Also refer
http://sap.ittoolbox.com/groups/technical-functional/sap-dev/bdc-table-control-668404
and
http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
Regards,
srinivas
<b>*reward for useful answers*</b> -
Hi Friends
I'm doing a BDC .... in the recording I have found that I've to change different line items.. the part of recording in which I'm facing problem is as below:
BDC_CURSOR VBAP-ABGRU(06)
VBAP-ABGRU(01) 10
VBAP-ABGRU(02) 10
VBAP-ABGRU(03) 10
VBAP-ABGRU(04) 10
VBAP-ABGRU(05) 10
VBAP-ABGRU(06) 10
now I have counted the item nos in a variable v_count. While filling the internal table of BDCdata how will i approach to fill different line items here as shown above.. for 1 item I have no prob....but for n no of items what will be the code of filling bdctab... please let me know....
Thanks
MoumitaHi moumita ....
Plz have a look......
How to deal with table control / step loop in BDC?
Steploop and table contol 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, 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 ABAP code has two purposes:
1. how to determine number of visible lines and how to calculte page number; (the 'calpage' routine has been modify to meet general purpose usage)
2. 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..)
Step1: 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)
Step2: 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)
Step3: write a subroutine calcalculating number of pages
(here, the name of actual parameter is the same as formal parameter)
global data: 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.
Step4 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.
Step5 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.
Step6 using field sysbol in your BDC, for example: in ME21, but you should calculate each item will correponding to which index
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.
Sample code
Following is a sample code of handling table control in BDC.
REPORT Y730_BDC5 .
*HANDLING TABLE CONTROL IN BDC
DATA : BEGIN OF IT_DUMMY OCCURS 0,
DUMMY(100) TYPE C,
END OF IT_DUMMY.
DATA : BEGIN OF IT_XK01 OCCURS 0,
LIFNR(10) TYPE C,
BUKRS(4) TYPE C,
EKORG(4) TYPE C,
KTOKK(4) TYPE C,
NAME1(30) TYPE C,
SORTL(10) TYPE C,
LAND1(3) TYPE C,
SPRAS(2) TYPE C,
AKONT(6) TYPE C,
FDGRV(2) TYPE C,
WAERS(3) TYPE C,
END OF IT_XK01,
BEGIN OF IT_BANK OCCURS 0,
BANKS(3) TYPE C,
BANKL(10) TYPE C,
BANKN(10) TYPE C,
KOINH(30) TYPE C,
LIFNR(10) TYPE C,
END OF IT_BANK.
DATA : IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE,
IT_BDCMSGCOLL LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = 'C:\VENDOR.TXT'
FILETYPE = 'ASC'
TABLES
DATA_TAB = IT_DUMMY.
LOOP AT IT_DUMMY.
IF IT_DUMMY-DUMMY+0(2) = '11'.
IT_XK01-LIFNR = IT_DUMMY-DUMMY+2(10).
IT_XK01-BUKRS = IT_DUMMY-DUMMY+12(4).
IT_XK01-EKORG = IT_DUMMY-DUMMY+16(4).
IT_XK01-KTOKK = IT_DUMMY-DUMMY+20(4).
IT_XK01-NAME1 = IT_DUMMY-DUMMY+24(30).
IT_XK01-SORTL = IT_DUMMY-DUMMY+54(10).
IT_XK01-LAND1 = IT_DUMMY-DUMMY+64(3).
IT_XK01-SPRAS = IT_DUMMY-DUMMY+67(2).
IT_XK01-AKONT = IT_DUMMY-DUMMY+69(6).
IT_XK01-FDGRV = IT_DUMMY-DUMMY+75(2).
IT_XK01-WAERS = IT_DUMMY-DUMMY+77(3).
APPEND IT_XK01.
ELSE.
IT_BANK-BANKS = IT_DUMMY-DUMMY+2(3).
IT_BANK-BANKL = IT_DUMMY-DUMMY+5(10).
IT_BANK-BANKN = IT_DUMMY-DUMMY+15(10).
IT_BANK-KOINH = IT_DUMMY-DUMMY+25(30).
IT_BANK-LIFNR = IT_DUMMY-DUMMY+55(10).
APPEND IT_BANK.
ENDIF.
ENDLOOP.
LOOP AT IT_XK01.
REFRESH IT_BDCDATA.
perform bdc_dynpro using 'SAPMF02K' '0100'.
perform bdc_field using 'BDC_CURSOR'
'RF02K-REF_LIFNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RF02K-LIFNR'
IT_XK01-LIFNR.
perform bdc_field using 'RF02K-BUKRS'
IT_XK01-BUKRS.
perform bdc_field using 'RF02K-EKORG'
IT_XK01-EKORG.
perform bdc_field using 'RF02K-KTOKK'
IT_XK01-KTOKK.
perform bdc_dynpro using 'SAPMF02K' '0110'.
perform bdc_field using 'BDC_CURSOR'
'LFA1-TELX1'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'LFA1-NAME1'
IT_XK01-NAME1.
perform bdc_field using 'LFA1-SORTL'
IT_XK01-SORTL.
perform bdc_field using 'LFA1-LAND1'
IT_XK01-LAND1.
perform bdc_field using 'LFA1-SPRAS'
IT_XK01-SPRAS.
perform bdc_dynpro using 'SAPMF02K' '0120'.
perform bdc_field using 'BDC_CURSOR'
'LFA1-KUNNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02K' '0130'.
perform bdc_field using 'BDC_CURSOR'
'LFBK-KOINH(02)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
DATA : FNAM(20) TYPE C,
IDX TYPE C.
MOVE 1 TO IDX.
LOOP AT IT_BANK WHERE LIFNR = IT_XK01-LIFNR.
CONCATENATE 'LFBK-BANKS(' IDX ')' INTO FNAM.
perform bdc_field using FNAM
IT_BANK-BANKS.
CONCATENATE 'LFBK-BANKL(' IDX ')' INTO FNAM.
perform bdc_field using FNAM
IT_BANK-BANKL.
CONCATENATE 'LFBK-BANKN(' IDX ')' INTO FNAM.
perform bdc_field using FNAM
IT_BANK-BANKN.
CONCATENATE 'LFBK-KOINH(' IDX ')' INTO FNAM.
perform bdc_field using FNAM
IT_BANK-KOINH.
IDX = IDX + 1.
ENDLOOP.
perform bdc_dynpro using 'SAPMF02K' '0130'.
perform bdc_field using 'BDC_CURSOR'
'LFBK-BANKS(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_dynpro using 'SAPMF02K' '0210'.
perform bdc_field using 'BDC_CURSOR'
'LFB1-FDGRV'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'LFB1-AKONT'
IT_XK01-AKONT.
perform bdc_field using 'LFB1-FDGRV'
IT_XK01-FDGRV.
perform bdc_dynpro using 'SAPMF02K' '0215'.
perform bdc_field using 'BDC_CURSOR'
'LFB1-ZTERM'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02K' '0220'.
perform bdc_field using 'BDC_CURSOR'
'LFB5-MAHNA'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPMF02K' '0310'.
perform bdc_field using 'BDC_CURSOR'
'LFM1-WAERS'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'LFM1-WAERS'
IT_XK01-WAERS.
perform bdc_dynpro using 'SAPMF02K' '0320'.
perform bdc_field using 'BDC_CURSOR'
'WYT3-PARVW(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
CALL TRANSACTION 'XK01' USING IT_BDCDATA
MODE 'A'
UPDATE 'S'
MESSAGES INTO IT_BDCMSGCOLL.
ENDLOOP.
FORM BDC_DYNPRO USING PROG SCR.
CLEAR IT_BDCDATA.
IT_BDCDATA-PROGRAM = PROG.
IT_BDCDATA-DYNPRO = SCR.
IT_BDCDATA-DYNBEGIN = 'X'.
APPEND IT_BDCDATA.
ENDFORM.
FORM BDC_FIELD USING FNAM FVAL.
CLEAR IT_BDCDATA.
IT_BDCDATA-FNAM = FNAM.
IT_BDCDATA-FVAL = FVAL.
APPEND IT_BDCDATA.
ENDFORM.
Regards Kaushik Datta -
More than 100 items in Form or Page
Can Apex allow more than 100 items in a page? I am getting message like
'Item count exceeds maximum of 100'.
Even data entered in the form for extra items over 100 is not posted to database.
Pl help or suggest any workaround.
I am using HTMLDB 2.0Example:
1. Create the test data
CREATE TABLE "TEST_TABLE1"
("KEY1" NUMBER(10) NOT NULL ,
"DESC" VARCHAR2(24) ,
"OPTION1" VARCHAR2(10) ,
"OPTION2" VARCHAR2(10) ,
"OPTION3" VARCHAR2(10) ,
"OPTION4" VARCHAR2(10) ,
"OPTION5" VARCHAR2(10) ,
"OPTION6" VARCHAR2(10) ,
"OPTION7" VARCHAR2(10) ,
"OPTION8" VARCHAR2(10) ,
"OPTION9" VARCHAR2(10) ,
"OPTION10" VARCHAR2(10) ,
"OPTION11" VARCHAR2(10) ) ;
INSERT INTO"TEST_TABLE1"
VALUES (1,'Row 1','Red','Blue','Green','Yellow','Orange','Black','Ivory','Purple','White','Lime','Gray');
INSERT INTO"TEST_TABLE1"
VALUES (2,'Row 2','Blue','Green','Yellow','Orange','Black','Ivory','Purple','White','Lime','Gray','Red');
INSERT INTO"TEST_TABLE1"
VALUES (3,'Row 3','Green','Yellow','Orange','Black','Ivory','Purple','White','Lime','Gray','Red','Blue');
INSERT INTO"TEST_TABLE1"
VALUES (4,'Row 4','Yellow','Orange','Black','Ivory','Purple','White','Lime','Gray','Red','Blue','Green');
INSERT INTO"TEST_TABLE1"
VALUES (5,'Row 5','Orange','Black','Ivory','Purple','White','Lime','Gray','Red','Blue','Green','Yellow');
INSERT INTO"TEST_TABLE1"
VALUES (6,'Row 6','Black','Ivory','Purple','White','Lime','Gray','Red','Blue','Green','Yellow','Orange');
INSERT INTO"TEST_TABLE1"
VALUES (7,'Row 7','Ivory','Purple','White','Lime','Gray','Red','Blue','Green','Yellow','Orange','Black');
INSERT INTO"TEST_TABLE1"
VALUES (8,'Row 8','Purple','White','Lime','Gray','Red','Blue','Green','Yellow','Orange','Black','Ivory');
INSERT INTO"TEST_TABLE1"
VALUES (9,'Row 9','White','Lime','Gray','Red','Blue','Green','Yellow','Orange','Black','Ivory','Purple');
INSERT INTO"TEST_TABLE1"
VALUES (10,'Row 10','Lime','Gray','Red','Blue','Green','Yellow','Orange','Black','Ivory','Purple','White');
2. Create a blank page.
3. Create a report region with the following query.
select
"DESC",
htmldb_item.hidden(1,KEY1) Key1,
htmldb_item.text(2,OPTION1,10,10) OPTION1,
htmldb_item.text(3,OPTION2,10,10) OPTION2,
htmldb_item.text(4,OPTION3,10,10) OPTION3,
htmldb_item.text(5,OPTION4,10,10) OPTION4,
htmldb_item.text(6,OPTION5,10,10) OPTION5,
htmldb_item.text(7,OPTION6,10,10) OPTION6,
htmldb_item.text(8,OPTION7,10,10) OPTION7,
htmldb_item.text(9,OPTION8,10,10) OPTION8,
htmldb_item.text(10,OPTION9,10,10) OPTION9,
htmldb_item.text(11,OPTION10,10,10) OPTION10,
htmldb_item.text(12,OPTION11,10,10) OPTION11
from test_table1
4. create a save button which branches to the same page
5. Create a page process that executes the following SQL when the button is pressed:
-- update Record
for i in 1..htmldb_application.g_f01.count
loop
update test_table1
set option1 = replace(htmldb_application.g_f02(i),'%'||'null%',NULL),
option2 = replace(htmldb_application.g_f03(i),'%'||'null%',NULL),
option3 = replace(htmldb_application.g_f04(i),'%'||'null%',NULL),
option4 = replace(htmldb_application.g_f05(i),'%'||'null%',NULL),
option5 = replace(htmldb_application.g_f06(i),'%'||'null%',NULL),
option6 = replace(htmldb_application.g_f07(i),'%'||'null%',NULL),
option7 = replace(htmldb_application.g_f08(i),'%'||'null%',NULL),
option8 = replace(htmldb_application.g_f09(i),'%'||'null%',NULL),
option9 = replace(htmldb_application.g_f10(i),'%'||'null%',NULL),
option10 = replace(htmldb_application.g_f11(i),'%'||'null%',NULL)
option11 = replace(htmldb_application.g_f12(i),'%'||'null%',NULL)
where key1 = htmldb_application.g_f01(i);
end loop;
6. Run the page (This page has 110 items)
If you have a table with more than 100 fields, you can try something like this:
Select 1, apex_item.text(1,field1,10,10),
apex_item.text(2,field2,10,10),
union all
Select 2, apex_item.text(1,field11,10,10),
apex_item.text(2,field12,10,10),
, field2, field3, field4, field5
Maybe you are looking for
-
I have a question about the combo packs for The Lion King. In the version details it gives the different versions of the movie and what is on them. I was wondering, what is the difference (if any) between the 2-disc blu-ray pack and the 2-disc DVD pa
-
SetEnabed() affect the cursor!
Call the setCursor() function of a JComponent's instance, when enabled the component(setEnabed(true) ), the cursor can show normally. while disnabled it(setEnabed(false) ), the cursor show the default cursor(not the one i set). Is it a java bug?can't
-
Audio Sounds Fine in Flash - Glitchy On Publish
I have AIFF streaming audio in Flash CS4 (does it in CS5 too) and it sounds fine in Flash, but when I publish it I get a glitch/noise sound in a few places. It does this no matter what audio format I export, including RAW. ??? The source doesn't have
-
i just installed jcreator pro on this computer, and although applets i had already made work fine, new applets are missing the nameofprogram.class file and I am getting runtime errors. any ideas?
-
¡Buenas a tod@s! Estoy programando varias VI como servicios web, y no consigo ver la manera de poder crear dichos WS en un servidor remoto. Mediante New>>WebService(RESTful) (en las Build Specifications de un Proyecto) creo los WS pero en el mismo PC