Hi All, How we can handle a table control in bdc - in detail its urgent pls
Hi All, How we can handle a table control in bdc - in detail its urgent. Please send me the explanation in detail.
Thanks®ards.
Bharat
hi,
Create Table Control
Step 1 (Create new structure for table control)
Type is name of structure (ZTC_EKKO) and press create
Step 2 (Create Program)
Goto transaction SE80(Object Navigator) -> Repository Browser -> Program.
Enter your program name, please ensure that is begins with SAPMZ
as this is a module pool (dialog program).
Press enter to create, and press yes!
Ensure that you create a top include, and press Enter.
Accept the name created for the top include.
Press Enter.
Press Save
Step 3 (Create TOP include)
Double click on the top include and enter following ABAP code:
Tables: ZTC_EKKO.
controls: tc100 type tableview using screen 100.
data: ok_code type sy-ucomm.
data: it_ekko type standard
table of ZTC_EKKO initial size 0,
wa_ekko type ZTC_EKKO.
data: ok_code type sy-ucomm.
Press Save and Activate
Step 4 (Create screen)
Right click the program to create a screen 100 for the dialog. Enter Short description, set screen type to Normal and enter 0 or blank into Next screen. Then move to Element List tab and enter the OK code as OK_CODE (i.e. the same as what you declared in the top include with data: ok_code type sy-ucomm).
Step 5 (Create table control)
Press the Layout button to bring up the screen painter editor.
Press table control button and drag it on to the screen, enter the name of table control created in TOP include (TC100). Now press the yellow button for attributes and set the table control as below options
Step 6 (Populate table control )
Press the orange button (Fields). On the next screen enter ZTC_EKKO and press the Get from Dict button. Select the fields you want (all) and press enter. Now drag them onto your Table Control.
Below is the result, there will been syntax errors if we check now! So Save and go back into the flow logic tab.
Step 7 (Create flow control )
Within the flow logic of screen 100 and create two modules, one to select the data from the database and the other to move the selected fields into the table control. Also insert the two loop statements to populate and retrieve the lines of the table control.
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
module data_retrieval.
loop at it_ekko into wa_ekko with control TC100.
module populate_screen.
endloop.
PROCESS AFTER INPUT.
loop at it_ekko.
endloop.
MODULE USER_COMMAND_0100.
Double click the module data_retrieval to create and click yes to get past the popup. Ensure that a new include is created to hold all the PBO modules (default). Press enter.
Select 10 rows of data from the EKKO table and load into the internal table it_ekko. Go back to the flow logic to load this data into the Table Control.
check this one
REPORT ZCALL_TRANS_TAB1 .
TABLES: LFA1,LFBK,lfb1.
data: BEGIN OF it_vendor occurs 0,
LIFNR LIKE LFA1-LIFNR,
bukrs like lfb1-bukrs,
END OF it_vendor.
DATA: BEGIN OF IT_BANK occurs 0,
LIFNR LIKE LFA1-LIFNR,
BANKS LIKE LFBK-BANKS,
BANKL LIKE LFBK-BANKL,
BANKN LIKE LFBK-BANKN,
koinh like lfbk-koinh,
END OF IT_BANK.
data: it_bdcdata like bdcdata occurs 0 with header line.
data: it_messages like bdcmsgcoll occurs 0 with header line.
*selection screen.
selection-screen: begin of block b1 with frame.
parameters: p_file like rlgrap-filename default 'c:/vendor.txt'
obligatory.
parameters: p_file1 like rlgrap-filename default 'c:/xyz.txt'
obligatory.
selection-screen: end of block b1.
*at selection screen.
at selection-screen on value-request for p_file.
perform f4_help using p_file.
at selection-screen on value-request for p_file1.
perform f4_help1 using p_file1.
*start of selection
start-of-selection.
*******uploading file
perform upload_file using p_file P_FILE1.
******open session.
perform populate_data.
*& Form f4_help
form f4_help using p_p_file.
data: l_file type ibipparms-path.
call function 'F4_FILENAME'
importing
file_name = l_file.
p_file = l_file.
endform. " f4_help
*& Form POPULATE_DATA
form populate_data .
DATA: L_STRING TYPE STRing.
DATA: L_COUNTER(2) TYPE n.
loop at it_vendor.
perform bdc_dynpro using 'SAPMF02K' '0106'.
perform bdc_field using 'BDC_CURSOR'
'RF02K-D0130'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RF02K-LIFNR'
it_vendor-lifnr.
perform bdc_field using 'RF02K-BUKRS'
it_vendor-bukrs.
perform bdc_field using 'RF02K-D0130'
'X'.
perform bdc_dynpro using 'SAPMF02K' '0130'.
perform bdc_field using 'BDC_CURSOR'
'LFBK-bankn(03)'.
perform bdc_field using 'BDC_OKCODE'
'=UPDA'.
*********bank details
CLEAR l_COUNTER.
LOOP AT IT_BANK WHERE LIFNR = IT_VENDOR-LIFNR.
l_COUNTER = l_COUNTER + 1.
clear l_string.
CONCATENATE 'lfbk-banks(' l_counter ')' into l_string.
perform bdc_field using l_string
it_bank-banks.
clear l_string.
CONCATENATE 'lfbk-bankl(' l_counter ')' into l_string.
perform bdc_field using l_string
it_bank-bankl.
clear l_string.
CONCATENATE 'lfbk-bankn(' l_counter ')' into l_string.
perform bdc_field using l_string
it_bank-bankn.
endloop.
******CALL TRANSACTION.
call transaction 'FK02' using it_bdcdata mode 'A'
messages into it_messages.
write:/ sy-subrc.
perform format_messages.
clear it_bdcdata.
refresh it_bdcdata.
endloop.
endform. " POPULATE_DATA
*& Form FORMAT_MESSAGES
form format_messages .
data: l_msg(100).
loop at it_messages.
call function 'FORMAT_MESSAGE'
exporting
id = it_messages-msgid
lang = sy-langu
no = it_messages-msgnr
v1 = it_messages-msgv1
v2 = it_messages-msgv2
v3 = it_messages-msgv3
v4 = it_messages-msgv4
importing
msg = l_msg
exceptions
not_found = 1
others = 2
write:/ l_msg.
endloop.
endform. " FORMAT_MESSAGES
*& Form bdc_dynpro
form bdc_dynpro using value(p_program)
value(p_screen).
it_bdcdata-program = p_program.
it_bdcdata-dynpro = p_screen.
it_bdcdata-dynbegin = 'X'.
append it_bdcdata.
clear it_bdcdata.
endform. " bdc_dynpro
*& Form bdc_field
form bdc_field using value(p_fnam)
value(p_fval).
it_bdcdata-fnam = p_fnam.
it_bdcdata-fval = p_fval.
append it_bdcdata.
clear it_bdcdata.
endform. " bdc_field
*& Form upload_file
form upload_file using p_p_file
p_p_file1.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
CODEPAGE = ' '
FILENAME = P_P_FILE
FILETYPE = 'DAT'
HEADLEN = ' '
LINE_EXIT = ' '
TRUNCLEN = ' '
USER_FORM = ' '
USER_PROG = ' '
DAT_D_FORMAT = ' '
IMPORTING
FILELENGTH =
TABLES
data_tab = IT_VENDOR
EXCEPTIONS
CONVERSION_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_READ_ERROR = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
NO_AUTHORITY = 10
OTHERS = 11
IF sy-subrc <> 0.
MESSAGE I000(ZZ) WITH 'UNABLE TO UPLOAD'.
STOP.
ENDIF.
*******UPLOADING BANK DETAILS
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
CODEPAGE = ' '
FILENAME = P_P_FILE1
FILETYPE = 'DAT'
HEADLEN = ' '
LINE_EXIT = ' '
TRUNCLEN = ' '
USER_FORM = ' '
USER_PROG = ' '
DAT_D_FORMAT = ' '
IMPORTING
FILELENGTH =
TABLES
data_tab = IT_BANK
EXCEPTIONS
CONVERSION_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_READ_ERROR = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
NO_AUTHORITY = 10
OTHERS = 11
IF sy-subrc <> 0.
MESSAGE I000(ZZ) WITH 'UNABLE TO UPLOAD'.
STOP.
ENDIF.
endform. " upload_file
*& Form f4_help1
-->P_P_FILE1 text
form f4_help1 using p_p_file1.
data:l_file1 type ibipparms-path.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = l_file1.
p_file1 = l_file1.
endform. " f4_help1
http://sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
Regards,
Sankar
Similar Messages
-
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 All,What is the concept of table control in bdc
Hi All,What is the concept of table control in bdc .Can u please explain in brief.How we have to handle the logic for va01 transaction .
Thanks®ards.
BharatHi Kaushik Datta ,
I already know for me51 ,but i am getting the problem for va01 while populating the item details in to the table control. The code which i have generated is :
please see the code and tell me where i should increment the counter for populating the item details
report ZBKVA01Y
no standard page heading line-size 255.
include bdcrecx1.
parameters: dataset(132) lower case.
DO NOT CHANGE - the generated data section - DO NOT CHANGE ***
If it is nessesary to change the data section use the rules:
1.) Each definition of a field exists of two lines
2.) The first line shows exactly the comment
'* data element: ' followed with the data element
which describes the field.
If you don't have a data element use the
comment without a data element name
3.) The second line shows the fieldname of the
structure, the fieldname must consist of
a fieldname and optional the character '_' and
three numbers and the field length in brackets
4.) Each field must be type C.
DATA: BEGIN OF IT_DUMMY OCCURS 0,
TEXT(1000),
END OF IT_DUMMY.
Generated data section with specific formatting - DO NOT CHANGE ***
data: begin of IT_HEADER OCCURS 0,
data element: AUART
AUART_001(004),
data element: VKORG
VKORG_002(004),
data element: VTWEG
VTWEG_003(002),
data element: SPART
SPART_004(002),
data element: BSTKD
BSTKD_005(035),
data element: BSTDK
BSTDK_006(010),
data element: KUNAG
KUNNR_007(010),
data element: KUNWE
KUNNR_008(010),
data element: ABHOZ
ABHOV_009(008),
data element: ABHOZ
ABHOB_010(008),
data element: PRSDT
PRSDT_011(010),
END OF IT_HEADER.
DATA: BEGIN OF IT_ITEM OCCURS 0,
data element: MATNR
MABNR_01_012(018),
data element: KWMENG
KWMENG_01_013(019),
end of IT_ITEM.
*DATA: DATE(10) TYPE C.
*DATA: I_DATE TYPE SY-DATUM.
*DATA: I_YEAR(4) TYPE C,
I_MONTH(2) TYPE C,
I_DAY(2) TYPE C .
*DATA:
End generated data section ***
start-of-selection.
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 = IT_DUMMY
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.
*perform open_dataset using dataset.
LOOP AT IT_DUMMY.
IF IT_DUMMY-TEXT+0(1) = 'H'.
IT_HEADER-AUART_001(004) = IT_DUMMY-TEXT+1(4).
data element: VKORG
IT_HEADER-VKORG_002(004) = IT_DUMMY-TEXT+5(4).
data element: VTWEG
IT_HEADER-VTWEG_003(002) = IT_DUMMY-TEXT+9(2).
data element: SPART
IT_HEADER-SPART_004(002) = IT_DUMMY-TEXT+11(2).
data element: BSTKD
IT_HEADER-BSTKD_005(035) = IT_DUMMY-TEXT+13(35).
data element: BSTDK
IT_HEADER-BSTDK_006(010) = IT_DUMMY-TEXT+48(8).
data element: KUNAG
IT_HEADER-KUNNR_007(010) = IT_DUMMY-TEXT+56(10).
data element: KUNWE
IT_HEADER-KUNNR_008(010) = IT_DUMMY-TEXT+66(10).
data element: ABHOZ
IT_HEADER-ABHOV_009(008) = IT_DUMMY-TEXT+76(6).
data element: ABHOZ
IT_HEADER-ABHOB_010(008) = IT_DUMMY-TEXT+82(6).
data element: PRSDT
IT_HEADER-PRSDT_011(010) = IT_DUMMY-TEXT+88(8).
APPEND IT_HEADER.
CLEAR IT_HEADER.
ELSEIF IT_DUMMY-TEXT+0(1) = 'I'.
data element: MATNR
IT_ITEM-MABNR_01_012(018) = IT_DUMMY-TEXT+1(18).
data element: KWMENG
IT_ITEM-KWMENG_01_013(019) = IT_DUMMY-TEXT+19(15).
APPEND IT_ITEM.
CLEAR IT_ITEM.
ENDIF.
ENDLOOP.
perform open_group.
LOOP AT IT_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'
IT_HEADER-AUART_001.
perform bdc_field using 'VBAK-VKORG'
IT_HEADER-VKORG_002.
perform bdc_field using 'VBAK-VTWEG'
IT_HEADER-VTWEG_003.
perform bdc_field using 'VBAK-SPART'
IT_HEADER-SPART_004.
perform bdc_dynpro using 'SAPMV45A' '4001'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'VBKD-BSTKD'
IT_HEADER-BSTKD_005.
perform bdc_field using 'VBKD-BSTDK'
IT_HEADER-BSTDK_006.
perform bdc_field using 'KUAGV-KUNNR'
IT_HEADER-KUNNR_007.
perform bdc_field using 'KUWEV-KUNNR'
IT_HEADER-KUNNR_008.
perform bdc_dynpro using 'SAPMSSY0' '0120'.
perform bdc_field using 'BDC_CURSOR'
'04/05'.
perform bdc_field using 'BDC_OKCODE'
'=CHOO'.
perform bdc_dynpro using 'SAPMV45A' '4001'.
perform bdc_field using 'VBAK-ABHOV'
IT_HEADER-ABHOV_009.
perform bdc_field using 'VBAK-ABHOB'
IT_HEADER-ABHOB_010.
perform bdc_field using 'VBKD-PRSDT'
IT_HEADER-PRSDT_011.
perform bdc_field using 'BDC_CURSOR'
'RV45A-KWMENG(01)'.
perform bdc_field using 'RV45A-MABNR(01)'
IT_ITEM-MABNR_01_012.
perform bdc_field using 'RV45A-KWMENG(01)'
IT_ITEM-KWMENG_01_013.
perform bdc_transaction using 'VA01'.
*enddo.
ENDLOOP.
perform close_group.
*perform close_dataset using dataset.
Thanks®ards.
Bharat . -
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 -
How to delete record from table control in BDC?
Hello friends,
I am running a BDC program to delete records.
I have file with following records and i got these records into t_itab.
Material Plant Start date End date Cost
MQ100001 S001 09/01/2008 09/31/2008 55.00
MQ100004 S002 09/01/2008 09/31/2008 56.00
MQ100008 S003 09/01/2008 09/31/2008 57.00
Now, I have BDC transaction in which table control screen which contains following structure.
MQ100001 S001 09/01/2008 09/31/2008 55.00
MQ100002 S002 09/01/2008 09/31/2008 56.00
MQ100004 S003 09/01/2008 09/31/2008 47.00
MQ100005 S004 09/01/2008 09/31/2008 25.00
MQ100006 S012 09/01/2008 09/31/2008 76.00
MQ100007 S033 09/01/2008 09/31/2008 17.00
MQ100008 S011 09/01/2008 09/31/2008 95.00
MQ100009 S002 09/01/2008 09/31/2008 46.00
I have recorded from SHDB in which first record will be delete.
So, when i loop through t_itab,instead of deleting MQ100001,MQ100004 and MQ100008 from BDC screen,
it is deleting MQ100001,MQ100002 and MQ100004 (first record for each process ).
Which i don't want to.
Is there any facility in BDC to put records on top which i want to delete?
Please guide me.
Regards,
RHHi,
While doing recording check for Filter button available for the table control, if it available then do the recording for the same.
Once it is done while passing the data from internal table put the value into Filter field.
Hope it resolves your issue.
Thanks & Regards.
Nagaraj Kalbavi -
How to delete record from table control using BDC?
Hello friends,
I am running a BDC program to delete records.
I have file with following records and i got these records into t_itab.
Material Plant Start date End date Cost
MQ100001 S001 09/01/2008 09/31/2008 55.00
MQ100004 S002 09/01/2008 09/31/2008 56.00
MQ100008 S003 09/01/2008 09/31/2008 57.00
Now, I have BDC transaction in which table control screen which contains following structure.
MQ100001 S001 09/01/2008 09/31/2008 55.00
MQ100002 S002 09/01/2008 09/31/2008 56.00
MQ100004 S003 09/01/2008 09/31/2008 47.00
MQ100005 S004 09/01/2008 09/31/2008 25.00
MQ100006 S012 09/01/2008 09/31/2008 76.00
MQ100007 S033 09/01/2008 09/31/2008 17.00
MQ100008 S011 09/01/2008 09/31/2008 95.00
MQ100009 S002 09/01/2008 09/31/2008 46.00
I have recorded from SHDB in which first record will be delete.
So, when i loop through t_itab,instead of deleting MQ100001,MQ100004 and MQ100008 from BDC screen,
it is deleting MQ100001,MQ100002 and MQ100004 (first record for each process ).
Which i don't want to.
Is there any facility in BDC to put records on top which i want to delete?
Please guide me.
Regards,
RHOne option is to identify the table and find out the location as the number of row which should be deleted from the table and then in the bdc program instead of postioning the cursor on the row 1(using the statement perform bdc_cursor ....(01)), replace the 01 with the row number.
Second option is that if a filter control is available for the table control, then filter the data each and every time with the material number to be deleted and then delete the first row.
Regards
Farzan -
Table control...? its urgent
Hi friends,
Can anyone gve me example table control program..
My requirement is I have to display blank table control.....but when user enetrs value.. and submits it should be added to the inetrnal table in my program please help......
Also if he wants to see the records in table control..which he enetered earlier the table should be displayed as populated..
Please help its urgent....points will be rewarded....Seet he following ex:
Created table control using wizard.
*& Module pool ZTEST_TBLCTRL
PROGRAM ZTEST_TBLCTRL.
***&SPWIZARD: DATA DECLARATION FOR TABLECONTROL 'TC1'
*&SPWIZARD: DEFINITION OF DDIC-TABLE
TABLES: ZFG_SRNO, ZFIH0004.
*&SPWIZARD: TYPE FOR THE DATA OF TABLECONTROL 'TC1'
*TYPES: BEGIN OF T_TC1,
ZSRNO LIKE ZFG_SRNO-ZSRNO,
SCRNAME LIKE ZFIH0004-SCRNAME,
END OF T_TC1.
*TYPES: BEGIN OF T_TC1.
STRUCTURE ZFG_SRNO.
END OF T_TC1.
*&SPWIZARD: INTERNAL TABLE FOR TABLECONTROL 'TC1'
*DATA: G_TC1_ITAB TYPE T_TC1 OCCURS 0 WITH HEADER LINE,
G_TC1_WA TYPE T_TC1. "work area
DATA: G_TC1_ITAB LIKE ZFG_SRNO OCCURS 0 WITH HEADER LINE,
G_TC1_WA LIKE G_TC1_ITAB. "work area
DATA: G_TC1_COPIED. "copy flag
*&SPWIZARD: DECLARATION OF TABLECONTROL 'TC1' ITSELF
CONTROLS: TC1 TYPE TABLEVIEW USING SCREEN 0100.
*&SPWIZARD: LINES OF TABLECONTROL 'TC1'
DATA: G_TC1_LINES LIKE SY-LOOPC.
DATA: OK_CODE LIKE SY-UCOMM,
S_CODE LIKE SY-UCOMM,
MARK.
DATA: T1(10).
*&SPWIZARD: OUTPUT MODULE FOR TC 'TC1'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: COPY DDIC-TABLE TO ITAB
MODULE TC1_INIT OUTPUT.
IF G_TC1_COPIED IS INITIAL.
*&SPWIZARD: COPY DDIC-TABLE 'ZFG_SRNO'
*&SPWIZARD: INTO INTERNAL TABLE 'g_TC1_itab'
SELECT * FROM ZFG_SRNO
INTO CORRESPONDING FIELDS
OF TABLE G_TC1_ITAB.
G_TC1_COPIED = 'X'.
REFRESH CONTROL 'TC1' FROM SCREEN '0100'.
IF T1 <> SPACE.
G_TC1_ITAB-ZSRNO = T1.
CLEAR T1.
APPEND G_TC1_ITAB.
REFRESH CONTROL 'TC1' FROM SCREEN '0100'.
ENDIF.
*TC1-TOP_LINE = 1.
ENDIF.
ENDMODULE.
*&SPWIZARD: OUTPUT MODULE FOR TC 'TC1'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: MOVE ITAB TO DYNPRO
MODULE TC1_MOVE OUTPUT.
MOVE-CORRESPONDING G_TC1_WA TO ZFG_SRNO.
if sy-subrc ne 0.
*append G_TC1_WA to G_TC1_ITAB.
*endif.
READ TABLE G_TC1_ITAB INDEX TC1-CURRENT_LINE.
IF SY-SUBRC = 0.
G_TC1_WA-ZSRNO = G_TC1_ITAB-ZSRNO.
ENDIF.
MOVE-CORRESPONDING G_TC1_ITAB TO ZFG_SRNO.
REFRESH CONTROL 'TC1' FROM SCREEN '8001'.
tc1-lines = G_TC1_LINES + 100.
ENDMODULE.
*&SPWIZARD: OUTPUT MODULE FOR TC 'TC1'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: GET LINES OF TABLECONTROL
MODULE TC1_GET_LINES OUTPUT.
G_TC1_LINES = SY-LOOPC.
ENDMODULE.
*&SPWIZARD: INPUT MODULE FOR TC 'TC1'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: MODIFY TABLE
MODULE TC1_MODIFY INPUT.
*break-point.
MOVE-CORRESPONDING ZFG_SRNO TO G_TC1_ITAB.
MODIFY G_TC1_ITAB INDEX TC1-CURRENT_LINE.
G_TC1_COPIED = 'X'.
REFRESH CONTROL 'TC1' FROM SCREEN '8001'.
MOVE-CORRESPONDING ZFG_SRNO TO G_TC1_WA.
MODIFY G_TC1_ITAB
FROM G_TC1_WA
INDEX TC1-CURRENT_LINE.
G_TC1_COPIED = 'X'.
if sy-subrc ne 0.
append G_TC1_WA to G_TC1_ITAB.
endif.
*modify G_TC1_ITAB INDEX TC1-CURRENT_LINE.
ENDMODULE.
*&SPWIZARD: INPUT MODULE FOR TC 'TC1'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: PROCESS USER COMMAND
MODULE TC1_USER_COMMAND INPUT.
OK_CODE = SY-UCOMM.
PERFORM USER_OK_TC USING 'TC1'
'G_TC1_ITAB'
'FLAG'
CHANGING OK_CODE.
SY-UCOMM = OK_CODE.
ENDMODULE.
INCLUDE TABLECONTROL_FORMS *
*& Form USER_OK_TC *
FORM USER_OK_TC USING P_TC_NAME TYPE DYNFNAM
P_TABLE_NAME
P_MARK_NAME
CHANGING P_OK LIKE SY-UCOMM.
&SPWIZARD: BEGIN OF LOCAL DATA----
DATA: L_OK TYPE SY-UCOMM,
L_OFFSET TYPE I.
&SPWIZARD: END OF LOCAL DATA----
*&SPWIZARD: Table control specific operations *
*&SPWIZARD: evaluate TC name and operations *
SEARCH P_OK FOR P_TC_NAME.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
L_OFFSET = STRLEN( P_TC_NAME ) + 1.
L_OK = P_OK+L_OFFSET.
*&SPWIZARD: execute general and TC specific operations *
CASE L_OK.
WHEN 'INSR'. "insert row
PERFORM FCODE_INSERT_ROW USING P_TC_NAME
P_TABLE_NAME.
CLEAR P_OK.
WHEN 'DELE'. "delete row
PERFORM FCODE_DELETE_ROW USING P_TC_NAME
P_TABLE_NAME
P_MARK_NAME.
CLEAR P_OK.
WHEN 'P--' OR "top of list
'P-' OR "previous page
'P+' OR "next page
'P++'. "bottom of list
PERFORM COMPUTE_SCROLLING_IN_TC USING P_TC_NAME
L_OK.
CLEAR P_OK.
WHEN 'L--'. "total left
PERFORM FCODE_TOTAL_LEFT USING P_TC_NAME.
WHEN 'L-'. "column left
PERFORM FCODE_COLUMN_LEFT USING P_TC_NAME.
WHEN 'R+'. "column right
PERFORM FCODE_COLUMN_RIGHT USING P_TC_NAME.
WHEN 'R++'. "total right
PERFORM FCODE_TOTAL_RIGHT USING P_TC_NAME.
WHEN 'MARK'. "mark all filled lines
PERFORM FCODE_TC_MARK_LINES USING P_TC_NAME
P_TABLE_NAME
P_MARK_NAME .
CLEAR P_OK.
WHEN 'DMRK'. "demark all filled lines
PERFORM FCODE_TC_DEMARK_LINES USING P_TC_NAME
P_TABLE_NAME
P_MARK_NAME .
CLEAR P_OK.
WHEN 'SASCEND' OR
'SDESCEND'. "sort column
PERFORM FCODE_SORT_TC USING P_TC_NAME
l_ok.
ENDCASE.
ENDFORM. " USER_OK_TC
*& Form FCODE_INSERT_ROW *
FORM fcode_insert_row
USING P_TC_NAME TYPE DYNFNAM
P_TABLE_NAME .
&SPWIZARD: BEGIN OF LOCAL DATA----
DATA L_LINES_NAME LIKE FELD-NAME.
DATA L_SELLINE LIKE SY-STEPL.
DATA L_LASTLINE TYPE I.
DATA L_LINE TYPE I.
DATA L_TABLE_NAME LIKE FELD-NAME.
FIELD-SYMBOLS <TC> TYPE CXTAB_CONTROL.
FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE.
FIELD-SYMBOLS <LINES> TYPE I.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (P_TC_NAME) TO <TC>.
*&SPWIZARD: get the table, which belongs to the tc *
CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body
ASSIGN (L_TABLE_NAME) TO <TABLE>. "not headerline
*&SPWIZARD: get looplines of TableControl *
CONCATENATE 'G_' P_TC_NAME '_LINES' INTO L_LINES_NAME.
ASSIGN (L_LINES_NAME) TO <LINES>.
*&SPWIZARD: get current line *
GET CURSOR LINE L_SELLINE.
IF SY-SUBRC <> 0. " append line to table
L_SELLINE = <TC>-LINES + 1.
*&SPWIZARD: set top line *
IF L_SELLINE > <LINES>.
<TC>-TOP_LINE = L_SELLINE - <LINES> + 1 .
ELSE.
<TC>-TOP_LINE = 1.
ENDIF.
ELSE. " insert line into table
L_SELLINE = <TC>-TOP_LINE + L_SELLINE - 1.
L_LASTLINE = <TC>-TOP_LINE + <LINES> - 1.
ENDIF.
*&SPWIZARD: set new cursor line *
L_LINE = L_SELLINE - <TC>-TOP_LINE + 1.
*&SPWIZARD: insert initial line *
INSERT INITIAL LINE INTO <TABLE> INDEX L_SELLINE.
<TC>-LINES = <TC>-LINES + 1.
*&SPWIZARD: set cursor *
SET CURSOR LINE L_LINE.
ENDFORM. " FCODE_INSERT_ROW
*& Form FCODE_DELETE_ROW *
FORM fcode_delete_row
USING P_TC_NAME TYPE DYNFNAM
P_TABLE_NAME
P_MARK_NAME .
&SPWIZARD: BEGIN OF LOCAL DATA----
DATA L_TABLE_NAME LIKE FELD-NAME.
FIELD-SYMBOLS <TC> TYPE cxtab_control.
FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE.
FIELD-SYMBOLS <WA>.
FIELD-SYMBOLS <MARK_FIELD>.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (P_TC_NAME) TO <TC>.
*&SPWIZARD: get the table, which belongs to the tc *
CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body
ASSIGN (L_TABLE_NAME) TO <TABLE>. "not headerline
*&SPWIZARD: delete marked lines *
DESCRIBE TABLE <TABLE> LINES <TC>-LINES.
LOOP AT <TABLE> ASSIGNING <WA>.
*&SPWIZARD: access to the component 'FLAG' of the table header *
ASSIGN COMPONENT P_MARK_NAME OF STRUCTURE <WA> TO <MARK_FIELD>.
IF <MARK_FIELD> = 'X'.
DELETE <TABLE> INDEX SYST-TABIX.
IF SY-SUBRC = 0.
<TC>-LINES = <TC>-LINES - 1.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " FCODE_DELETE_ROW
*& Form COMPUTE_SCROLLING_IN_TC
text
-->P_TC_NAME name of tablecontrol
-->P_OK ok code
FORM COMPUTE_SCROLLING_IN_TC USING P_TC_NAME
P_OK.
&SPWIZARD: BEGIN OF LOCAL DATA----
DATA L_TC_NEW_TOP_LINE TYPE I.
DATA L_TC_NAME LIKE FELD-NAME.
DATA L_TC_LINES_NAME LIKE FELD-NAME.
DATA L_TC_FIELD_NAME LIKE FELD-NAME.
FIELD-SYMBOLS <TC> TYPE cxtab_control.
FIELD-SYMBOLS <LINES> TYPE I.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (P_TC_NAME) TO <TC>.
*&SPWIZARD: get looplines of TableControl *
CONCATENATE 'G_' P_TC_NAME '_LINES' INTO L_TC_LINES_NAME.
ASSIGN (L_TC_LINES_NAME) TO <LINES>.
*&SPWIZARD: is no line filled? *
IF <TC>-LINES = 0.
*&SPWIZARD: yes, ... *
L_TC_NEW_TOP_LINE = 1.
ELSE.
*&SPWIZARD: no, ... *
CALL FUNCTION 'SCROLLING_IN_TABLE'
EXPORTING
ENTRY_ACT = <TC>-TOP_LINE
ENTRY_FROM = 1
ENTRY_TO = <TC>-LINES
LAST_PAGE_FULL = 'X'
LOOPS = <LINES>
OK_CODE = P_OK
OVERLAPPING = 'X'
IMPORTING
ENTRY_NEW = L_TC_NEW_TOP_LINE
EXCEPTIONS
NO_ENTRY_OR_PAGE_ACT = 01
NO_ENTRY_TO = 02
NO_OK_CODE_OR_PAGE_GO = 03
OTHERS = 0.
ENDIF.
*&SPWIZARD: get actual tc and column *
GET CURSOR FIELD L_TC_FIELD_NAME
AREA L_TC_NAME.
IF SYST-SUBRC = 0.
IF L_TC_NAME = P_TC_NAME.
*&SPWIZARD: et actual column *
SET CURSOR FIELD L_TC_FIELD_NAME LINE 1.
ENDIF.
ENDIF.
*&SPWIZARD: set the new top line *
<TC>-TOP_LINE = L_TC_NEW_TOP_LINE.
ENDFORM. " COMPUTE_SCROLLING_IN_TC
*& Form FCODE_TC_MARK_LINES
marks all TableControl lines
-->P_TC_NAME name of tablecontrol
FORM FCODE_TC_MARK_LINES USING P_TC_NAME
P_TABLE_NAME
P_MARK_NAME.
&SPWIZARD: EGIN OF LOCAL DATA----
DATA L_TABLE_NAME LIKE FELD-NAME.
FIELD-SYMBOLS <TC> TYPE cxtab_control.
FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE.
FIELD-SYMBOLS <WA>.
FIELD-SYMBOLS <MARK_FIELD>.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (P_TC_NAME) TO <TC>.
*&SPWIZARD: get the table, which belongs to the tc *
CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body
ASSIGN (L_TABLE_NAME) TO <TABLE>. "not headerline
*&SPWIZARD: mark all filled lines *
LOOP AT <TABLE> ASSIGNING <WA>.
*&SPWIZARD: access to the component 'FLAG' of the table header *
ASSIGN COMPONENT P_MARK_NAME OF STRUCTURE <WA> TO <MARK_FIELD>.
<MARK_FIELD> = 'X'.
ENDLOOP.
ENDFORM. "fcode_tc_mark_lines
*& Form FCODE_TC_DEMARK_LINES
demarks all TableControl lines
-->P_TC_NAME name of tablecontrol
FORM FCODE_TC_DEMARK_LINES USING P_TC_NAME
P_TABLE_NAME
P_MARK_NAME .
&SPWIZARD: BEGIN OF LOCAL DATA----
DATA L_TABLE_NAME LIKE FELD-NAME.
FIELD-SYMBOLS <TC> TYPE cxtab_control.
FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE.
FIELD-SYMBOLS <WA>.
FIELD-SYMBOLS <MARK_FIELD>.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (P_TC_NAME) TO <TC>.
*&SPWIZARD: get the table, which belongs to the tc *
CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body
ASSIGN (L_TABLE_NAME) TO <TABLE>. "not headerline
*&SPWIZARD: demark all filled lines *
LOOP AT <TABLE> ASSIGNING <WA>.
*&SPWIZARD: access to the component 'FLAG' of the table header *
ASSIGN COMPONENT P_MARK_NAME OF STRUCTURE <WA> TO <MARK_FIELD>.
<MARK_FIELD> = SPACE.
ENDLOOP.
ENDFORM. "fcode_tc_mark_lines
*& Module D20XX_INIT OUTPUT
text
MODULE D20XX_INIT OUTPUT.
*if screen-name = 'ZSRNO'.
SCREEN-INPUT = 0.
SCREEN-COLOR = 0.
MODIFY SCREEN.
endif.
ENDMODULE. " D20XX_INIT OUTPUT
*& Module STATUS_0100 OUTPUT
text
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'xxxxxxxx'.
SET TITLEBAR 'xxx'.
*CLEAR R1_REF.
DO 30 TIMES.
APPEND G_TC1_ITAB.
ENDDO.
DESCRIBE TABLE G_TC1_ITAB LINES TC1-LINES.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module TAB1_INIT OUTPUT
text
MODULE TAB1_INIT OUTPUT.
ENDMODULE. " TAB1_INIT OUTPUT
*& Module USER_COMMAND_0100 INPUT
text
MODULE USER_COMMAND_0100 INPUT.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Module MESSAGE INPUT
text
MODULE MESSAGE INPUT.
OK_CODE = SY-UCOMM.
S_CODE = OK_CODE.
CLEAR OK_CODE.
if S_CODE = 'DELE'.
loop at G_TC1_ITAB.
if G_TC1_ITAB-scrname = 'X'.
delete g_tc1_itab.
endif.
endloop.
ELSEIF S_CODE = 'SAVE'.
G_TC1_WA-ZSRNO = T1.
MOVE-CORRESPONDING G_TC1_WA TO ZFG_SRNO.
REFRESH CONTROL 'TC1' FROM SCREEN '0100'.
ENDIF.
ENDMODULE. " MESSAGE INPUT
*& Module DELETE_RECORD INPUT
text
MODULE DELETE_RECORD INPUT.
IF MARK = 'X' AND S_CODE = 'DELE'.
DELETE TABLE G_TC1_ITAB FROM ZFG_SRNO.
DESCRIBE TABLE G_TC1_ITAB LINES TC1-LINES.
ENDIF.
ENDMODULE. " DELETE_RECORD INPUT
*********************Screen modules*********************
PROCESS BEFORE OUTPUT.
*&SPWIZARD: PBO FLOW LOGIC FOR TABLECONTROL 'TC1'
MODULE TC1_INIT.
*&SPWIZARD: MODULE TC1_CHANGE_TC_ATTR.
*&SPWIZARD: MODULE TC1_CHANGE_COL_ATTR.
LOOP AT G_TC1_ITAB
INTO G_TC1_WA
WITH CONTROL TC1
CURSOR TC1-CURRENT_LINE.
*&SPWIZARD: MODULE TC1_CHANGE_FIELD_ATTR
MODULE TC1_MOVE.
MODULE TAB1_INIT.
MODULE TC1_GET_LINES.
ENDLOOP.
MODULE D20XX_INIT.
MODULE STATUS_0100.
PROCESS AFTER INPUT.
*&SPWIZARD: PAI FLOW LOGIC FOR TABLECONTROL 'TC1'
*BREAK POINT.
LOOP AT G_TC1_ITAB.
CHAIN.
FIELD ZFG_SRNO-ZSRNO.
MODULE TC1_MODIFY ON CHAIN-REQUEST.
MODULE TC1_MODIFY.
ENDCHAIN.
MODULE MESSAGE .
MODULE DELETE_RECORD.
ENDLOOP.
MODULE TC1_USER_COMMAND.
*&SPWIZARD: MODULE TC1_CHANGE_TC_ATTR.
*&SPWIZARD: MODULE TC1_CHANGE_COL_ATTR.
MODULE USER_COMMAND_0100. -
How populate the data in table control in BDC?
pls urgent?
hi,
see the below code .
FORM create_bdc_session .
DATA : w_saved_tx.
DATA g_r_itab TYPE typ_itab_rec.
CLEAR g_t_itab.
CLEAR g_r_itab.
LOOP AT g_t_itab INTO g_r_itab.
skip error lines
IF g_r_itab-ebeln = 'ERROR'.
CONTINUE.
ENDIF.
open Bdc session
AT FIRST.
PERFORM bdc_open_group.
ENDAT.
g_t_itab = g_r_itab.
On change in agreement number
AT NEW ebeln.
PERFORM bdc_header.
CLEAR: w_dtl_cnt_i, w_line_i.
ENDAT.
save at full page
IF w_line_i > 11.
PERFORM bdc_save.
PERFORM bdc_header_change.
w_line_i = 1.
ENDIF.
detail material processing
PERFORM bdc_detail.
CLEAR w_saved_tx .
save at end of agreement
AT END OF ebeln.
IF w_saved_tx NE 'Y' AND w_dtl_cnt_i > 0.
PERFORM bdc_save.
ENDIF.
w_saved_tx = 'Y'.
ENDAT.
ENDLOOP.
PERFORM bdc_close_group.
ENDFORM. " CREATE_BDC_SESSION
*& Form BDC_OPEN_GROUP
text
--> p1 text
<-- p2 text
FORM bdc_open_group .
DATA w_user_tx LIKE apqi-userid.
w_user_tx = sy-uname.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
client = sy-mandt
group = p_bdc
keep = 'X'
user = w_user_tx
EXCEPTIONS
client_invalid = 01
destination_invalid = 02
group_invalid = 03
holddate_invalid = 04
internal_error = 05
queue_error = 06
running = 07
user_invalid = 08.
CASE sy-subrc.
WHEN 0.
WHEN OTHERS.
WRITE: / 'BDC OPEN ERROR', sy-subrc.
ENDCASE.
ENDFORM. " BDC_OPEN_GROUP
*& Form BDC_HEADER
text
--> p1 text
<-- p2 text
FORM bdc_header .
REFRESH bdcdata.
CLEAR bdcdata.
determine now if text exists
CLEAR w_text_lines_i.
Transaction ME31K.
PERFORM bdc_dynpro USING 'SAPMM06E' '0200'.
PERFORM bdc_field USING 'BDC_OKCODE' '/00'.
PERFORM bdc_field USING 'EKKO-LIFNR' g_t_itab-lifnr.
PERFORM bdc_field USING 'RM06E-EVART' 'MK'.
PERFORM bdc_field USING 'RM06E-EVRTN' g_t_itab-ebeln.
PERFORM bdc_field USING 'EKKO-EKORG' g_t_itab-ekorg.
PERFORM bdc_field USING 'EKKO-EKGRP' g_t_itab-ekgrp.
Item category is on a detail line, but is entered on the entry screen
IF g_t_itab-pstyp = '3'.
g_t_itab-pstyp = 'L'.
ELSE.
CLEAR g_t_itab-pstyp.
ENDIF.
PERFORM bdc_field USING 'RM06E-EPSTP' g_t_itab-pstyp.
PERFORM bdc_field USING 'RM06E-WERKS' p_nwerks.
PERFORM bdc_field USING 'RM06E-LGORT' g_t_itab-lgort.
PERFORM bdc_dynpro USING 'SAPMM06E' '0201'.
PERFORM bdc_field USING 'BDC_OKCODE' '/00'.
PERFORM bdc_field USING 'EKKO-WAERS' g_t_itab-waers.
WRITE sy-datum TO w_date_tx DD/MM/YYYY.
PERFORM bdc_field USING 'EKKO-KDATB' '01.06.2004'.
PERFORM bdc_field USING 'EKKO-KDATE' '31.12.2999'.
w_tcode = 'ME31K'.
ENDFORM. " BDC_HEADER
*& Form BDC_SAVE
text
--> p1 text
<-- p2 text
FORM bdc_save .
final save
PERFORM bdc_dynpro USING 'SAPMM06E' '0220'.
PERFORM bdc_field USING 'BDC_OKCODE' '=BU'.
needed for some boxes (save anyway message)
PERFORM bdc_dynpro USING 'SAPLSPO1' '0300'.
PERFORM bdc_field USING 'BDC_OKCODE' '=YES'.
Insert the transaction into the BDC session.
PERFORM bdc_insert USING w_tcode.
REFRESH bdcdata.
CLEAR bdcdata.
ENDFORM. " BDC_SAVE
*& Form BDC_HEADER_change
text
--> p1 text
<-- p2 text
FORM bdc_header_change .
DATA: w_pos LIKE rm06e-ebelp.
REFRESH bdcdata.
CLEAR bdcdata.
determine now if text exists
CLEAR w_text_lines_i.
Transaction ME32K.
PERFORM bdc_dynpro USING 'SAPMM06E' '0205'.
PERFORM bdc_field USING 'BDC_OKCODE' '/00'.
PERFORM bdc_field USING 'RM06E-EVRTN' g_t_itab-ebeln.
PERFORM bdc_dynpro USING 'SAPMM06E' '0220'.
PERFORM bdc_field USING 'BDC_OKCODE' '/00'.
w_pos = g_t_itab-ebelp - 10.
PERFORM bdc_field USING 'RM06E-EBELP' w_pos.
w_tcode = 'ME32K'.
ENDFORM. " BDC_HEADER_change
*& Form BDC_INSERT
text
-->P_W_TCODE text
FORM bdc_insert USING p_w_tcode.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
tcode = w_tcode
TABLES
dynprotab = bdcdata
EXCEPTIONS
internal_error = 01
not_open = 02
queue_error = 03
tcode_invalid = 04.
CASE sy-subrc.
WHEN 0.
WHEN OTHERS.
WRITE: / 'BDC INSERT ERROR', sy-subrc.
ENDCASE.
ENDFORM. " BDC_INSERT
*& Form BDC_CLOSE_GROUP
text
--> p1 text
<-- p2 text
FORM bdc_close_group .
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
not_open = 1
queue_error = 2
OTHERS = 3.
CASE sy-subrc.
WHEN 0.
WHEN OTHERS.
WRITE: / 'BDC CLOSE ERROR', sy-subrc.
ENDCASE.
ENDFORM. " BDC_CLOSE_GROUP
*& Form bdc_dynpro
text
-->P_0658 text
-->P_0659 text
FORM bdc_dynpro USING program dynpro.
CLEAR bdcdata.
bdcdata-program = program.
bdcdata-dynpro = dynpro.
bdcdata-dynbegin = 'X'.
APPEND bdcdata.
ENDFORM. "BDC_DYNPRO
*& Form BDC_FIELD
text
-->P_0688 text
-->P_W_POS text
FORM bdc_field USING field value.
CLEAR bdcdata.
bdcdata-fnam = field.
bdcdata-fval = value.
APPEND bdcdata.
ENDFORM. "BDC_FIELD
*& Form load_dataset
text
--> p1 text
<-- p2 text
FORM load_dataset .
load dataset
LOOP AT g_t_itab INTO g_r_itab.
Load dataset with records needed for direct input
MOVE-CORRESPONDING g_r_itab TO g_t_itab.
AT NEW ebeln.
PERFORM load_dataset_mbepoh USING w_phys_outfil1_tx.
ENDAT.
PERFORM load_dataset_mbepoi USING w_phys_outfil1_tx.
ENDLOOP.
ENDFORM. " load_dataset
*& Form load_dataset_mbepoh
text
-->P_W_PHYS_OUTFIL1_TX text
FORM load_dataset_mbepoh USING p_dataset.
CLEAR rec1.
MOVE-CORRESPONDING g_t_itab TO rec1.
rec1-stype = '1'.
rec1-ernam = sy-uname.
TRANSFER rec1 TO p_dataset.
ENDFORM. " load_dataset_mbepoh
*& Form load_dataset_mbepoi
text
-->P_W_PHYS_OUTFIL1_TX text
FORM load_dataset_mbepoi USING p_dataset.
CLEAR rec2.
fields for MBEPOH
ADD 1 TO w_good_i.
MOVE-CORRESPONDING g_t_itab TO rec2.
rec2-stype = '2'.
rec2-werks = p_nwerks.
rec2-ematn = g_t_itab-matnr.
TRANSFER rec2 TO p_dataset.
ENDFORM. " load_dataset_mbepoi
*& Form BDC_DETAIL
text
--> p1 text
<-- p2 text
FORM bdc_detail .
DATA: w_ktmng_tx(11),
w_peinh_tx(5) TYPE c,
w_price_p(13) TYPE p DECIMALS 6,
w_price2_p(13) TYPE p DECIMALS 2,
w_price3_p(13) TYPE p DECIMALS 3,
w_price0_p(13) TYPE p DECIMALS 0,
w_cent_p TYPE p DECIMALS 2,
w_peinh_n(5) TYPE n,
w_price_tx(14).
accumulate lines to determine if page_down required
ADD 1 TO w_addit_i.
ADD 1 TO w_dtl_cnt_i.
ADD 1 TO w_line_i.
IF w_line_i > 12.
w_line_i = 2.
PERFORM bdc_dynpro USING 'SAPMM06E' '0220'.
PERFORM bdc_field USING 'BDC_OKCODE' '=NP'.
ENDIF.
get material unit of measure
CLEAR mara-meins.
SELECT SINGLE * FROM mara WHERE matnr = g_t_itab-matnr.
w_price_tx = g_t_itab-netpr.
w_peinh_tx = g_t_itab-peinh.
IF g_t_itab-ktmng = 0.
g_t_itab-ktmng = 1.
ENDIF.
w_ktmng_tx = g_t_itab-ktmng.
get decimal places of currency
TCURX-CURRDEC = 2.
SELECT SINGLE * FROM TCURX WHERE CURRKEY = g_t_itab-waers.
multiply Price
W_PRICE_P = g_t_itab-netpr.
CASE TCURX-CURRDEC.
WHEN 0.
W_PRICE_P = g_t_itab-netpr * 100.
W_PRICE0_P = W_PRICE_P.
W_PRICE_TX = W_PRICE0_P.
WHEN 2.
W_PRICE2_P = W_PRICE_P.
W_PRICE_TX = W_PRICE2_P.
WHEN 3.
W_PRICE3_P = W_PRICE_P.
W_PRICE_TX = W_PRICE3_P.
ENDCASE.
material overview screen (with enter)
PERFORM bdc_dynpro USING 'SAPMM06E' '0220'.
PERFORM bdc_field USING 'BDC_OKCODE' '=DETA'.
PERFORM bdc_field_idx USING 'RM06E-TCSELFLAG' 'X' w_line_i.
PERFORM bdc_field_idx USING 'EKPO-EMATN' g_t_itab-matnr w_line_i.
PERFORM bdc_field_idx USING 'EKPO-KTMNG' w_ktmng_tx w_line_i.
PERFORM bdc_field_idx USING 'EKPO-NETPR' w_price_tx w_line_i.
PERFORM bdc_field_idx USING 'EKPO-PEINH' w_peinh_tx w_line_i.
PERFORM bdc_field_idx USING 'EKPO-BPRME' mara-meins w_line_i.
PERFORM bdc_field_idx USING 'EKPO-WERKS' p_nwerks w_line_i.
PERFORM bdc_field_idx USING 'EKPO-LGORT' g_t_itab-lgort w_line_i.
IF g_t_itab-pstyp = '3'.
g_t_itab-pstyp = 'L'.
ELSE.
CLEAR g_t_itab-pstyp.
ENDIF.
PERFORM bdc_field_idx USING 'RM06E-EPSTP' g_t_itab-pstyp w_line_i.
item details screen
PERFORM bdc_dynpro USING 'SAPMM06E' '0211'.
PERFORM bdc_field USING 'BDC_OKCODE' '=OR'.
PERFORM bdc_field USING 'EKPO-SPINF' 'B'.
PERFORM bdc_field USING 'EKPO-BSTAE' '0001'.
PERFORM bdc_field USING 'EKPO-MWSKZ' g_t_itab-mwskz.
PERFORM bdc_field USING 'EKPO-IDNLF' g_t_itab-idnlf.
PERFORM bdc_field USING 'EKPO-REPOS' 'X'.
PERFORM bdc_field USING 'EKPO-EVERS' g_t_itab-evers.
PERFORM bdc_field USING 'EKPO-KZABS' 'X'.
PERFORM bdc_field USING 'EKPO-NETPR' w_price_tx. "deliberate
PERFORM bdc_field USING 'EKPO-PEINH' w_peinh_tx . "Overwriting
Source list
PERFORM bdc_dynpro USING 'SAPLMEOR' '0220'.
PERFORM bdc_field USING 'BDC_OKCODE' 'EN'.
PERFORM bdc_field USING 'BDC_CURSOR' 'EORD-AUTET(01)'.
PERFORM bdc_field USING 'EORD-VDATU(01)' '01062004'.
PERFORM bdc_field USING 'EORD-BDATU(01)' '31122999'.
PERFORM bdc_field USING 'EORD-FEBEL(01)' ' '.
PERFORM bdc_field USING 'EORD-AUTET(01)' '1'.
GOTO Conditions
PERFORM bdc_dynpro USING 'SAPMM06E' '0211'.
PERFORM bdc_field USING 'BDC_OKCODE' '=KO'.
PERFORM bdc_dynpro USING 'SAPMV13A' '0201'.
PERFORM bdc_field USING 'BDC_OKCODE' '=BACK'.
ENDFORM. " BDC_DETAIL
*& Form BDC_FIELD_IDX
text
-->P_1390 text
-->P_G_T_ITAB_PSTYP text
-->P_W_LINE_I text
FORM bdc_field_idx USING field LIKE bdcdata-fnam
value p_index TYPE i.
DATA: w_index_tx(2).
UNPACK p_index TO w_index_tx.
CLEAR bdcdata.
CONCATENATE field '(' w_index_tx ')' INTO field.
bdcdata-fnam = field.
bdcdata-fval = value.
APPEND bdcdata.
ENDFORM. " BDC_FIELD_IDX
regards, -
How to bring cursor in Table control??
Hi to all
How to bring cursor in Table control when entering into screen
can anyone tell me??? pls explain with example..
thanks
senthilHi,
Check the below code
data l_tc_name like feld-name.
data l_tc_field_name like feld-name.
get actual tc and column
get cursor field l_tc_field_name
area l_tc_name.
Regards,
Vind -
How can we handle table control in BDC?
Hi,
How can we handle table control in BDC?
regards
eswarhi,
check this example:
http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
ex:
*& Report ZSR_BDC_TBCTRL
REPORT ZSR_BDC_TBCTRL
NO STANDARD PAGE HEADING LINE-SIZE 255.
TABLES : RF02K,LFA1,LFBK.
DATA : BEGIN OF IT_VEN OCCURS 0,
LIFNR LIKE RF02K-LIFNR,
KTOKK LIKE RF02K-KTOKK,
NAME1 LIKE LFA1-NAME1,
SORTL LIKE LFA1-SORTL,
LAND1 LIKE LFA1-LAND1,
SPRAS LIKE LFA1-SPRAS,
BANKS(6) TYPE C,
BANKL(17) TYPE C,
BANKN(19) TYPE C,
END OF IT_VEN.
DATA : BEGIN OF BANKS OCCURS 0,
BANKS LIKE LFBK-BANKS,
END OF BANKS,
BEGIN OF BANKL OCCURS 0,
BANKL LIKE LFBK-BANKL,
END OF BANKL,
BEGIN OF BANKN OCCURS 0,
BANKN LIKE LFBK-BANKN,
END OF BANKN.
DATA : FLD(20) TYPE C,
CNT(2) TYPE N.
DATA : BDCTAB LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
INCLUDE BDCRECX1.
START-OF-SELECTION.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'Z:\sr.TXT'
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 = IT_VEN
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
PERFORM OPEN_GROUP.
LOOP AT IT_VEN.
REFRESH BDCDATA.
REFRESH : BANKS,BANKL,BANKN..
SPLIT IT_VEN-BANKS AT ',' INTO TABLE BANKS.
SPLIT IT_VEN-BANKL AT ',' INTO TABLE BANKL.
SPLIT IT_VEN-BANKN AT ',' INTO TABLE BANKN.
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'
IT_VEN-LIFNR.
PERFORM BDC_FIELD USING 'RF02K-KTOKK'
IT_VEN-KTOKK.
PERFORM BDC_DYNPRO USING 'SAPMF02K' '0110'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'LFA1-SPRAS'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'LFA1-NAME1'
IT_VEN-NAME1.
PERFORM BDC_FIELD USING 'LFA1-SORTL'
IT_VEN-SORTL.
PERFORM BDC_FIELD USING 'LFA1-LAND1'
IT_VEN-LAND1.
PERFORM BDC_FIELD USING 'LFA1-SPRAS'
IT_VEN-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-BANKN(02)'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.
*perform bdc_field using 'LFBK-BANKS(01)'
'DE'.
*perform bdc_field using 'LFBK-BANKS(02)'
'DE'.
*perform bdc_field using 'LFBK-BANKL(01)'
'10020030'.
*perform bdc_field using 'LFBK-BANKL(02)'
'67270003'.
*perform bdc_field using 'LFBK-BANKN(01)'
'12345'.
*perform bdc_field using 'LFBK-BANKN(02)'
'66666'.
MOVE 1 TO CNT.
LOOP AT BANKS.
CONCATENATE 'LFBK-BANKS(' CNT ') ' INTO FLD.
PERFORM BDC_FIELD USING FLD BANKS-BANKS.
CNT = CNT + 1.
ENDLOOP.
MOVE 1 TO CNT.
LOOP AT BANKL.
CONCATENATE 'LFBK-BANKL(' CNT ') ' INTO FLD.
PERFORM BDC_FIELD USING FLD BANKL-BANKL.
CNT = CNT + 1.
ENDLOOP.
MOVE 1 TO CNT.
LOOP AT BANKN.
CONCATENATE 'LFBK-BANKN(' CNT ') ' INTO FLD.
PERFORM BDC_FIELD USING FLD BANKN-BANKN.
CNT = CNT + 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 'SAPLSPO1' '0300'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=YES'.
PERFORM BDC_TRANSACTION USING 'XK01'.
ENDLOOP.
PERFORM CLOSE_GROUP. -
How to handle the table control in bapi?
how to handle the table control in bapi? example va01.
i pass multiple line item what is the procedure?
header detail same .
eample ship to party
sale to party.
line item mulptiple
10 mat1
2o mat2
30 mat3.
in bapi we can pass sinle line item.
any way to handle multiple line item pass through the bapi.
Message was edited by:
Karthikeyan PanduranganBAPI is not going through the screen flow logic so you need not to worry about the table control. Just check in the BAPi there must be one table parameter for line items just pass one int table with your data to that table parameter it will automatically update the tables.
Regards
shiba dutta -
How to handle table control in BDC while uploading item details for anorder
How to handle table control in BDC while uploading item details for an order?
What is the use of CTU_PARAMS structure in BDC?
In Finance I have done some changes to the layout set by coping to a zscript(duning letter) and how can assign the print program?
What is the process to test the finance script?
How can I see the print preview whether it is coming correctly or not?
Thanks in advance.
Regards.
Abhilash.hi,
for the bdc control refer the following link:
http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
ctu_params:
refer to the link
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/abap/dataTransfers-LSMW%2CALE%2C+BDC
reward if useful,
thanks and regards -
How to handle Table control in BDC
How to handle Table control in BDC
HI,
Table Control in BDC
HI,
Refer the link:
http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
The concept is easy: it has to indicate the index of the table control in the field name, so if you have to populate the first record of table control:
BDC-FIELDNAME = <FIELDNAME>(01).
If you fill the second row:
BDC-FIELDNAME = <FIELDNAME>(02).
and so....
Now the problem is usually on how many records you have to load, because u can fill only the rows of table control available in the screen, If you have more records than it can be displayed yuo have to simulate the command to go next page.
The number of recod can be displayed can depend on pc resolution and many program haven't command to go to next page (in this case it could be impossible create a BDC program9.
A way to create a bdc program resolution indipendent is to work on the first and second row.
- Place the first hit in the first row of bdc;
- Place the second insert in the second row of bdc;
- Place the last hit to the top of table control;
- Place the next hit in the second row;
- Place the last hit to the top of table control;
- Place the next hit in the second row;
- .... and so
For more info: Search in SDN with TABLE CONTROL IN BDC.
Will get a lot of related links.
<b>Reward points if this Helps.
Manish</b> -
How to handle Table control in BDC? Difference between BDC & LSMW?
Hi
How to handle Table control in BDC? Difference between BDC & LSMW?
Regards,
RaghuHi ,
the diff b/w normal BDC and with table control is that with table control u can enter as many lineitems as u want..so during recording if u r entering 3 line items..then the program will show (1), (2) and (3) with that.
chane that fixed no to variable.
check that sample code.
in this for new customer...any no of items can be entered.
LOOP AT t_cusdata.
REFRESH t_bdcdata.
ON CHANGE OF t_cusdata-kunnr.
initial screen.
PERFORM bdc_dynpro USING 'SAPMV10A' '0100'.
PERFORM bdc_field USING 'BDC_CURSOR'
'MV10A-VTWEG'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'MV10A-KUNNR'
t_cusdata-kunnr.
PERFORM bdc_field USING 'MV10A-VKORG'
t_cusdata-vkorg. "'HCL'.
PERFORM bdc_field USING 'MV10A-VTWEG'
t_cusdata-vtweg. "'HL'.
DATA: fnam(20) TYPE c,
fnam1(20) TYPE c,
idx(2) TYPE c.
MOVE 1 TO idx.
LOOP AT t_matdata WHERE kunnr = t_cusdata-kunnr.
PERFORM bdc_dynpro USING 'SAPMV10A' '0200'.
CONCATENATE 'MV10A-KDMAT(' idx ')' INTO fnam.
PERFORM bdc_field USING 'BDC_CURSOR'
fnam.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
CONCATENATE 'MV10A-MATNR(' idx ')' INTO fnam1.
PERFORM bdc_field USING fnam1
t_matdata-matnr. "'FIN50'.
PERFORM bdc_field USING fnam
t_matdata-kdmat. "'ABCD'.
idx = idx + 1.
ENDLOOP.
PERFORM bdc_dynpro USING 'SAPMV10A' '0200'.
PERFORM bdc_field USING 'BDC_CURSOR'
'MV10A-MATNR(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=SICH'.
CALL TRANSACTION 'VD51' USING t_bdcdata MODE 'A' .
UPDATE 'S' MESSAGES INTO t_err_mes.
Regards,
Sonika -
How to handle the table control While working with LSMW?
How to handle the table control While working with LSMW?
its possible in lsmw,
Hi,
LSMW will have a Indicator for headr and itam, i do not remember the correct field, but it will have an indicator, check the fields, there will be a single charecter lenght field, that should be the indicator, and using that we can write the logic.
check that single charecter field, it that is X that means the header record is processed, and do the items.
and, this is another way, try this out also
YOu can do this in "Define Source Structures" step,
the HEADER is defined first,
then the DETAIL below the HEADER.
add the fields to the structures.
Both should have some common key field
Please take care that the name of the common field is the same.
Once you do this it is linked. The you have a header and item corresponding to that header. then run the LSMW as you would.
Thanks
Maybe you are looking for
-
How to play two videos at the same time
Hi everyone! Ok, so what I'm trying to do is basically play two videos, which are already saved on the computer, at the same time. I can get one video to play, but when i try to start another it just displays a blank screen. import javax.swing.*; imp
-
Using one copy of Windows to install via boot camp and on a virtual machine?
I have a copy on windows 7 coming in the post and I was wondering if it is possible to install windows 7 via boot camp when I want to do something more memory intensive such as gaming and also install it on a virtual machine such as virtual box just
-
Brightness OSD not working in 64 bit Windows 7
Hi, After having used the laptop for a long time with a 32 bit Windows 7, I've upgraded the RAM and added an SSD, and reinstalled with a 64 bit Windows 7. Everything works great, some things even better than before (used to have occasional problems h
-
I presently use an older AirPort Extreme but my reception comes & goes. Does this occur with the newer version?
-
I've created a music file in garage band that I want to use as background music for my website. Unfortunately it needs to be in swf format. Does anyone know how to make that happen? Thanks Vicki