BDC Recording for Table Control
dears,
I am using BDC for posting payments by TCode FP05.
after processing two payment items i am getting the following error.
"Runtime error SAPSQL_ARRAY_INSERT_DUPREC has occurred"
but when i repeat the same recording in foreground it processes the payment sucessfully.
wht could be wrong with the recording?
how to record for table control?
Bye
Hi Syed,
I could find few notes for the array insert duplicate runtime error.
136433
191544
You can find may in OSS.
Cheers
Vinod
Similar Messages
-
how to write BDC coding based on Table Controls...
http://www.sap-basis-abap.com/abap/handling-table-control-in-bdc.htm
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.
Cheers
VJ -
Hi Friends,
I have an issue i am stuck here,
i have to create BDC Program for XK01 tcode,
and my requirement is that,
i have three users first user want only three colum and second user want four column
and third user want five column in table control,
so how could i achieve it,
please hekp me out.
Thanks
VikashHi Vikash,
FORM bdc_dynpro USING p_program p_dynpro.
IF user-one.
FORM bdc_field USING fnam1 fval.
FORM bdc_field USING fnam2 fval.
FORM bdc_field USING fnam3 fval.
ELSEIF user-two.
FORM bdc_field USING fnam1 fval.
FORM bdc_field USING fnam2 fval.
FORM bdc_field USING fnam3 fval.
FORM bdc_field USING fnam4 fval.
ELSEIF user-three.
FORM bdc_field USING fnam1 fval.
FORM bdc_field USING fnam2 fval.
FORM bdc_field USING fnam3 fval.
FORM bdc_field USING fnam4 fval.
FORM bdc_field USING fnam5 fval.
ENDIF.
Does this make sense?
regards,
Archer. -
BDC for existing record in table control
Hi,
I have a requirement to change existing records in table control through BDC. Is there any way I can choose the respective record from Table Control through BDC dynamically.
Regards
Akash/J4I/015PER, this transaction is used for adding permits to Operation in WEC. It has list of operations in Table Control. Permit can be added for choosing the operation from table control.
Our custom program is designed to add permits for the operation. So if I have to use the above transaction for adding permits, then first I have to choose the correct operation from the table control and then add permit. -
How to give line items in flatfile while doing BDC for Table control
Hi all,
I am writing BDC for Multiple line items and Transaction is : FSE5N.
How do i give the data in the flat file. I mean how do we give the multiple line items in flat file , i.e for second line item again we have to header data or not ?
ex:
1015;ALL;demo;kr;INR;01;0001;3000172;100
1015;ALL;demo;kr;INR;01;0001;3000172;200
for first lineitem : 3000172;100
for 2nd line item : 3000172; 200.
header data : 1015;ALL;demo;kr;INR;01;0001.
Thanks in advance
krupaliHii ,
u can give in the same format as u have done in the example.
A B C D E F G H I
1015;ALL;demo;kr;INR;01;0001;3000172;100
1015;ALL;demo;kr;INR;01;0001;3000172;200
and while writing the loop u can give
loop at it_head.
loop at it_head where a = it_head-A and b = it_head-B ..........upto G = it_head-G.
endloop.
endloop.
check this
http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
Neeraj -
How can we do the validation for non visible records in table control.
Hi Experts,
I have a table control which displays list of material details. I have a button to upload the material details from excel file to table control directly. I have to validate all the customers which are exist in the table. But my item (Material) table control displays only 5 rows i.e only 5 entries are visible in module pool screen. The validation is done for 5 records only in PAI event, but i need to do validation for rest of the records too (Which are not visible on items table), if validation fails then needs to display error message.
How can we do the validation for non visible records in table control.
Regards,
BujjiHi,
try validating material before displaying it in table control...'
Rgds/Abhhi -
Wanted a code for table controls in bdc
hi,
i have written code for uploading data into FB60 transaction but i have a serious problem with that code.
after entering 10 line items and when i am entering 11th item it is saying that the screen doesnot contain 11th line.
so please modify my program or if you can please send me a program for handling table controls more line details.
thanks and i will surely provide ten points to it.
my code is
LOOP AT I_PREPARE INTO WA_PREPARE.
V_VALUE = WA_PREPARE-LINE+0(2).
CASE V_VALUE.
WHEN 'A'.
CLEAR:V_DCNT.
*UPLOAD THE COMPANY CODE TO FB60.
*PERFORM.......USING WA_PREPARE-LINE+2(4).
*? filling header data
*********to initialize the company code and to get the popup**********
PERFORM SET_BUKRS.
PERFORM BDC_DYNPRO USING 'SAPLACHD' '1000'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'BKPF-BUKRS'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.
BUKRS = WA_PREPARE-LINE+2(4).
PERFORM BDC_FIELD USING 'BKPF-BUKRS'
BUKRS.
PERFORM BDC_DYNPRO USING 'SAPMF05A' '1100'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'RF05A-BUSCS'
'R'.
*UPLOAD THE VENDOR NUMBER TO FB60
*PERFORM.......USING WA_PREPARE-LINE+45(10).
ACCNT = WA_PREPARE-LINE+45(10).
PERFORM BDC_FIELD USING 'INVFO-ACCNT'
ACCNT.
*UPLOAD THE DATE TO FB60
WRITE WA_PREPARE-LINE+34(8) TO V_DATE USING EDIT MASK ' . . .'
*PERFORM.......USING V_DATE.
PERFORM BDC_FIELD USING 'INVFO-BLDAT'
'15.09.2004'.
PERFORM BDC_FIELD USING 'INVFO-BUDAT'
'15.09.2004'.
*UPLOAD THE AMOUNT TO FB60
*PERFORM.......USING WA_PREPARE-LINE+85(15).
WRBTR = WA_PREPARE-LINE+85(15).
PERFORM BDC_FIELD USING 'INVFO-WRBTR'
WRBTR.
*UPLOAD THE CURRENCY CODE TO FB60
*PERFORM.......USING WA_PREPARE-LINE+100(3).
WAERS = WA_PREPARE-LINE+100(3).
PERFORM BDC_FIELD USING 'INVFO-WAERS'
WAERS.
WHEN 'D'.
V_DCNT = V_DCNT + 1.
IF V_DCNT GT 04.
V_DCNT = 04.
ENDIF.
*UPLOAD THE G/L ACC. TO FB60.
*PERFORM.......USING WA_PREPARE-LINE+51(20).
*? filling item data
CONCATENATE 'ACGL_ITEM-WRBTR(' V_DCNT ')' INTO FNAM.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
FNAM.
CONCATENATE 'ACGL_ITEM-HKONT(' V_DCNT ')' INTO FNAM.
HKONT = WA_PREPARE-LINE+51(20).
PERFORM BDC_FIELD USING FNAM
HKONT.
*UPLOAD THE AMOUNT TO FB60(ACGL_ITEM-WRBTR)
*PERFORM........USING WA_PREPARE-LINE+121(15).
CONCATENATE 'ACGL_ITEM-WRBTR(' V_DCNT ')' INTO FNAM.
WRBTR = WA_PREPARE-LINE+75(15).
PERFORM BDC_FIELD USING FNAM
WRBTR.
PERFORM BDC_DYNPRO USING 'SAPMF05A' '1100'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=0006'.
PERFORM BDC_FIELD USING 'RF05A-BUSCS'
'R'.
ENDCASE.hi,
check this example:
http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
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 update record in Table control
Dear Friends,
I have table control that has space for 10 records but i need to update 15 record from the flat file which is getting into the table how can i do this.
Regards,
MAHENDRA.Hi,
you record for an item and then click on page down and save it.use the loop on this bdc to populate the the bdc table no need to do manually.
LOOP AT l_i_dettab_item INTO l_wa_dettab_item..
l_cursor = l_cursor + 1.
IF l_cursor GT 1.
PERFORM bdc_field USING 'BDC_OKCODE'
'=P+'.
ENDIF.
PERFORM cursor_pos_notation USING 'V_EAN_DET001- GTIN_VARIANT_TYP'
l_cursor
CHANGING l_cursor_notation.
PERFORM cursor_pos_notation USING 'V_EAN_DET001-VTWEG'
l_cursor
CHANGING l_cursor_notation.
PERFORM bdc_field USING l_cursor_notation
l_wa_dettab_item-vtweg.
PERFORM cursor_pos_notation USING 'V_EAN_DET001-DATEFROM'
l_cursor
CHANGING l_cursor_notation.
PERFORM bdc_field USING l_cursor_notation
l_v_date.
PERFORM bdc_field USING 'BDC_CURSOR'
l_cursor_notation.
PERFORM bdc_field USING 'BDC_OKCODE'
'=SAVE'.
ENDLOOP.
Here my ok code for page down is =P+ so i am looping on the table control data and then populating the bdc table after this i will populate the remaing info required for the call transaction and refresh bdcdata.
thats it no need to do recording 1000 times.
now if u do like this it doesn't depend on the number of records on table control.
it will take all the records.
Reward if useful.
Regards,
sasi
Regards,
sasi -
hi
i have been asked to do bdc recording for the transaction mek1 through the call transaction method.can u people plss tell me how to go abt it?Hi,
You can Record using the Tcode SHDB and format the program and use.
You can use VK11 tcode also which is similar to MEK1.
see the sample code for VK11 ; You can change as per your requirement.
report ZSDBDCP_PRICING no standard page heading
line-size 255.
Includes
include zbdcrecx1.
Internal Tables
*--Internal Table To hold condition records data from flat file.
Data: begin of it_pricing occurs 0,
key(4),
f1(4),
f2(4),
f3(2),
f4(18),
f5(16),
end of it_pricing.
*--Internal Table To hold condition records header .
data : begin of it_header occurs 0,
key(4),
f1(4),
f2(4),
f3(2),
end of it_header.
*--Internal Table To hold condition records details .
data : begin of it_details occurs 0,
key(4),
f4(18),
f5(16),
end of it_details.
data : v_sno(2),
v_rows type i,
v_fname(40).
start-of-selection.
refresh : it_pricing,it_header,it_details.
clear : it_pricing,it_header,it_details.
CALL FUNCTION 'UPLOAD'
EXPORTING
FILENAME = 'C:\WINDOWS\Desktop\pricing.txt'
FILETYPE = 'DAT'
TABLES
DATA_TAB = it_pricing
EXCEPTIONS
CONVERSION_ERROR = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
OTHERS = 7.
WRITE : / 'Condition Records ', P_FNAME, ' on ', SY-DATUM.
OPEN DATASET P_FNAME FOR INPUT IN TEXT MODE.
if sy-subrc ne 0.
write : / 'File could not be uploaded.. Check file name.'.
stop.
endif.
CLEAR : it_pricing[], it_pricing.
DO.
READ DATASET P_FNAME INTO V_STR.
IF SY-SUBRC NE 0.
EXIT.
ENDIF.
write v_str.
translate v_str using '#/'.
SPLIT V_STR AT ',' INTO it_pricing-key
it_pricing-F1 it_pricing-F2 it_pricing-F3
it_pricing-F4 it_pricing-F5 .
APPEND it_pricing.
CLEAR it_pricing.
ENDDO.
IF it_pricing[] IS INITIAL.
WRITE : / 'No data found to upload'.
STOP.
ENDIF.
loop at it_pricing.
At new key.
read table it_pricing index sy-tabix.
move-corresponding it_pricing to it_header.
append it_header.
clear it_header.
endat.
move-corresponding it_pricing to it_details.
append it_details.
clear it_details.
endloop.
perform open_group.
v_rows = sy-srows - 8.
loop at it_header.
perform bdc_dynpro using 'SAPMV13A' '0100'.
perform bdc_field using 'BDC_CURSOR'
'RV13A-KSCHL'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RV13A-KSCHL'
it_header-f1.
perform bdc_dynpro using 'SAPMV13A' '1004'.
perform bdc_field using 'BDC_CURSOR'
'KONP-KBETR(01)'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'KOMG-VKORG'
it_header-f2.
perform bdc_field using 'KOMG-VTWEG'
it_header-f3.
**Table Control
v_sno = 0.
loop at it_details where key eq it_header-key.
v_sno = v_sno + 1.
clear v_fname.
CONCATENATE 'KOMG-MATNR(' V_SNO ')' INTO V_FNAME.
perform bdc_field using v_fname
it_details-f4.
clear v_fname.
CONCATENATE 'KONP-KBETR(' V_SNO ')' INTO V_FNAME.
perform bdc_field using v_fname
it_details-f5.
if v_sno eq v_rows.
v_sno = 0.
perform bdc_dynpro using 'SAPMV13A' '1004'.
perform bdc_field using 'BDC_OKCODE'
'=P+'.
perform bdc_dynpro using 'SAPMV13A' '1004'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
endif.
endloop.
*--Save
perform bdc_dynpro using 'SAPMV13A' '1004'.
perform bdc_field using 'BDC_OKCODE'
'=SICH'.
perform bdc_transaction using 'VK11'.
endloop.
perform close_group.
Regards,
Anji -
Bdc recording for trancastion ME01
Hi,
Can u help me in BDC recording for transaction 'ME01' .
I have no idea for transaction 'ME01' & here i like to know how to handle table ctr during bdc recording?
give sample code if possible.
ThanksSee the sample attached code for ME51 using table control.
similarly record the same for ME01 and copy the TC logic from this.
REPORT zmm_pr_upload_mat
NO STANDARD PAGE HEADING
LINE-SIZE 255.
Standard Include for Selection Screen
INCLUDE bdcrecx1.
Internal Table for Upload Data
DATA: BEGIN OF i_pr OCCURS 0,
Header Screen
sno(3), " SNo
bsart(004), " PR Type
epstp(001), " Item Category
knttp(001), " Account Assignment
eeind(010), " Delivery Date
lpein(001), " Category of Del Date
werks(004), " Plant
lgort(004), " Storage Location
ekgrp(003), " Purchasing Group
matkl(009), " Material Group
bednr(010), " Tracking No
afnam(012), " Requisitioner
Item Details
matnr(018), " Material No
menge(017), " Quantity
badat(010),
frgdt(010),
preis(014), " Valuation Price
waers(005), " Currency
peinh(005),
wepos(001),
repos(001),
sakto(010), " GL Account
kostl(010), " Cost Center
bnfpo(005),
END OF i_pr.
Internal Table for header Data
DATA: BEGIN OF it_header OCCURS 0,
sno(3), " SNo
bsart(004), " PR Type
epstp(001), " Item Category
knttp(001), " Account Assignment
eeind(010), " Delivery Date
werks(004), " Plant
lgort(004), " Storage Location
ekgrp(003), " Purchasing Group
matkl(009), " Material Group
bednr(010), " Tracking No
afnam(012), " Requisitioner
END OF it_header.
Internal Table for Item Data
DATA: BEGIN OF it_item OCCURS 0,
sno(3), " SNo
matnr(018), " Material No
menge(017), " Quantity
preis(014), " Valuation Price
sakto(010), " GL Account
kostl(010), " Cost Center
END OF it_item.
Data Variables & Constants
CONSTANTS : c_x VALUE 'X'. " Flag
DATA : v_l(2), " Counter
v_rowno(5), " Row No
v_2(2), " Counter
v_rows LIKE sy-srows, " Rows in TC
v_field(45). " String
Parameters
PARAMETERS: p_file LIKE ibipparms-path. " Filename
At selection-screen on Value Request for file Name
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
Get the F4 Values for the File
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
IMPORTING
file_name = p_file.
Start of Selection
START-OF-SELECTION.
Open the BDC Session
PERFORM open_group.
Upload the File into internal Table
CALL FUNCTION 'UPLOAD'
EXPORTING
filename = p_file
filetype = 'DAT'
TABLES
data_tab = i_pr
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.
SORT i_pr BY sno.
LOOP AT i_pr.
MOVE-CORRESPONDING i_pr TO it_item.
APPEND it_item.
CLEAR it_item.
AT END OF sno.
READ TABLE i_pr INDEX sy-tabix.
MOVE-CORRESPONDING i_pr TO it_header.
APPEND it_header.
CLEAR it_header.
ENDAT.
ENDLOOP.
SORT it_header BY sno.
SORT it_item BY sno.
v_rows = sy-srows - 6.
Upload the Data from Internal Table
LOOP AT it_header.
Header Data
PERFORM bdc_dynpro USING 'SAPMM06B' '0100'.
PERFORM bdc_field USING 'BDC_CURSOR'
'EBAN-BEDNR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'EBAN-BSART'
it_header-bsart.
PERFORM bdc_field USING 'RM06B-EPSTP'
it_header-epstp.
PERFORM bdc_field USING 'EBAN-KNTTP'
it_header-knttp.
PERFORM bdc_field USING 'RM06B-EEIND'
it_header-eeind.
PERFORM bdc_field USING 'RM06B-LPEIN'
it_header-lpein.
PERFORM bdc_field USING 'EBAN-WERKS'
it_header-werks.
PERFORM bdc_field USING 'EBAN-LGORT'
it_header-lgort.
PERFORM bdc_field USING 'EBAN-EKGRP'
it_header-ekgrp.
PERFORM bdc_field USING 'EBAN-MATKL'
it_header-matkl.
PERFORM bdc_field USING 'EBAN-BEDNR'
it_header-bednr.
PERFORM bdc_field USING 'EBAN-AFNAM'
it_header-afnam.
Item Details
v_l = 0.
To add no. of rows
v_2 = 0 .
As the screen is showing 13 rows defaulted to 130
v_rowno = 130 .
LOOP AT it_item WHERE sno = it_header-sno.
v_l = v_l + 1.
IF v_l = 14 .
IF v_2 = 12 .
v_2 = 12 .
v_l = 2 .
From second time onwards it is displaying 12 rows only
v_rowno = v_rowno + 120 .
PERFORM bdc_dynpro USING 'SAPMM06B' '0106'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RM06B-BNFPO'.
PERFORM bdc_field USING 'RM06B-BNFPO'
v_rowno.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
ELSE.
V_2 initialized to 12 for second screen purpose
v_2 = 12 .
v_l = 2 .
PERFORM bdc_dynpro USING 'SAPMM06B' '0106'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RM06B-BNFPO'.
PERFORM bdc_field USING 'RM06B-BNFPO'
v_rowno .
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
ENDIF.
ENDIF.
PERFORM bdc_dynpro USING 'SAPMM06B' '0106'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
CLEAR v_field.
CONCATENATE 'EBAN-MATNR(' v_l ')' INTO v_field.
PERFORM bdc_field USING v_field it_item-matnr.
CLEAR v_field.
CONCATENATE 'EBAN-MENGE(' v_l ')' INTO v_field.
PERFORM bdc_field USING v_field it_item-menge.
PERFORM bdc_dynpro USING 'SAPMM06B' '0102'.
PERFORM bdc_field USING 'BDC_CURSOR'
'EBAN-PREIS'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'EBAN-PREIS'
it_item-preis.
PERFORM bdc_dynpro USING 'SAPMM06B' '0505'.
PERFORM bdc_field USING 'BDC_CURSOR'
'EBKN-SAKTO'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTE'.
PERFORM bdc_field USING 'EBKN-SAKTO'
it_item-sakto.
Cost Center
PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.
PERFORM bdc_field USING 'BDC_CURSOR'
'COBL-KOSTL'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTE'.
PERFORM bdc_field USING 'COBL-KOSTL'
it_item-kostl.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTE'.
ENDLOOP.
PERFORM bdc_dynpro USING 'SAPMM06B' '0106'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RM06B-BNFPO'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BU'.
Call The Transaction
PERFORM bdc_transaction USING 'ME51'.
ENDLOOP.
Close the BDC Session
PERFORM close_group.
reward if useful
Regards
Vasu -
Function module for table control
Hi experts,
I am creating the BDC program, In that I need to select the particular item from the table control say for example item 0010 or 0020 based on the input file and need to process from there.
Is there any function module to select the particular item by passing item no say 0010 or 0020.
Thanks in advance
saiHi
I suppose there is no function module for table control.
below solution might be useful to you.
1) Do BDC recording for the table control with each condition you would like to incorporate in your program.
2) copy the code of Table Control recording in your program and place the code in Loop of internal table.
3) based on the condition call the respective BDC recording of the table control
4) By the above steps you can manage the table control based on the condition.
Regards
Santosh Kumaar.M -
Add a new record to table control
Dear all,
How to add a new blank record to a table control?
Following code is not working for adding a new blank record to a table control
MODULE USER_COMMAND_0100 INPUT.
SAVE_OK = OK_CODE.
CLEAR OK_CODE.
CASE SAVE_OK.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'APND'. " A button "Add" to add a new record to table control
REFRESH IT_KNA1.
CLEAR IT_KNA1.
APPEND IT_KNA1.
ENDCASE.
ENDMODULE.
Thanks youHope you have done all table control specific coding
refer this example program
http://help.sap.com/saphelp_nw04/helpdata/en/9f/dbac5e35c111d1829f0000e829fbfe/content.htm -
Duplicate records in TABLE CONTROL
Hi folks,
i am doing a module pool where my internal table (itab) data is comming to table ontrol(ctrl).then i need to select one record in table control & then i press REFRESH push button.
after putting the refresh button, some new records are comming to that same internal table.then i need to display the modified internal table (some new records are added) data in the table control.
The modified internal table data is comming to the table control but to the last of table control, some records are repeating.
before comming to table control, i checked the modified itab. it contains correct data.i.e it contains 15 records.(previously i have 5 records.after REFRESH button 10 more records are added.). but when this table is comming to table control, it contains some 100 record.i should get only 15 record.
why these records r repeting. how to delete the duplicate records from table control?
plz suggest me where i am doing mistake.
correct answer will be rewarded
Thanks & RegardsHi ,
Thanks for ur help. but i should not refresh the internal table as some records r already present.after putting the REFRESH button, some new records r appending to this existing table.then i am going to display the previous records & the new records as well.
i checked the internal table after modification.it contains actual number of records. but after comming to table control , more records r comming.
is this the problem with scrolling or waht?
plz suggest where i am doing mistake.i am giving my coding below.
PROCESS BEFORE OUTPUT.
MODULE STATUS_0200.
module tc_shelf_change_tc_attr.
loop at object_tab1
with control tablctrl
cursor tablctrl-current_line.
module tc_shelf_get_lines.
endloop.
PROCESS AFTER INPUT.
module set_exit AT EXIT-COMMAND.
loop at object_tab1.
chain.
field: object_tab1-prueflos,
object_tab1-matnr.
module shelf_modify on chain-request.
endchain.
field object_tab1-idx
module shelf_mark on request.
endloop.
module shelf_user_command.
module user_command_0200.
***INCLUDE Y_RQEEAL10_STATUS_0200O01 .
*& Module STATUS_0200 OUTPUT
text
MODULE STATUS_0200 OUTPUT.
SET PF-STATUS 'MAIN'.
SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0200 OUTPUT
*& Module tc_shelf_change_tc_attr OUTPUT
text
MODULE tc_shelf_change_tc_attr OUTPUT.
delete adjacent duplicates from object_tab1 comparing prueflos matnr.
describe table object_tab1 lines tablctrl-lines.
ENDMODULE. " tc_shelf_change_tc_attr OUTPUT
*& Module tc_shelf_get_lines OUTPUT
text
MODULE tc_shelf_get_lines OUTPUT.
data: g_tc_shelf_lines like sy-loopc.
if tablctrl-current_line > tablctrl-lines.
stop.
endif.
g_tc_tablctrl_lines = sy-loopc.
*refresh control tablctrl from screen 0200.
ENDMODULE. " tc_shelf_get_lines OUTPUT
***INCLUDE Y_RQEEAL10_SHELF_MODIFYI01 .
*& Module shelf_modify INPUT
text
MODULE shelf_modify INPUT.
modify object_tab1
index tablctrl-current_line.
ENDMODULE. " shelf_modify INPUT
*& Module set_exit INPUT
text
module set_exit INPUT.
leave program.
endmodule. " set_exit INPUT
*& Module shelf_mark INPUT
text
MODULE shelf_mark INPUT.
data: g_shelf_wa2 like line of object_tab1.
if tablctrl-line_sel_mode = 1
and object_tab1-idx = 'X'.
loop at object_tab1 into g_shelf_wa2
where idx = 'X'.
g_shelf_wa2-idx = ''.
modify object_tab1
from g_shelf_wa2
transporting idx.
endloop.
endif.
modify object_tab1
index tablctrl-current_line
transporting idx plnty plnnr plnal.
ENDMODULE. " shelf_mark INPUT
*& Module shelf_user_command INPUT
text
MODULE shelf_user_command INPUT.
ok_code = sy-ucomm.
perform user_ok_tc using 'TABLCTRL'
'OBJECT_TAB1'
changing ok_code.
sy-ucomm = ok_code.
ENDMODULE. " shelf_user_command INPUT
*& Module user_command_0100 INPUT
text
MODULE user_command_0200 INPUT.
data:v_line(3).
case OK_CODE.
when 'LAST'.
read table object_tab1 with key idx = 'X'.
if sy-subrc = 0.
select * from qals
where enstehdat <= object_tab1-enstehdat
and plnty ne space
and plnnr ne space
and plnal ne space.
if sy-dbcnt > 0.
if qals-enstehdat = object_tab1-enstehdat.
check qals-entstezeit < object_tab1-entstezeit.
move-corresponding qals to object_tab2.
append object_tab2.
else.
move-corresponding qals to object_tab2.
append object_tab2.
endif.
endif.
endselect.
sort object_tab2 by enstehdat entstezeit descending.
loop at object_tab2 to 25.
if not object_tab2-prueflos is initial.
append object_tab2 to object_tab1.
endif.
clear object_tab2.
endloop.
endif.
when 'SAVE'.
loop at object_tab1 where idx = 'X'.
if ( not object_tab1-plnty is initial and
not object_tab1-plnnr is initial and
not object_tab1-plnal is initial ).
select single * from qals into corresponding fields of wa_qals
where prueflos = object_tab1-prueflos.
if sy-subrc = 0.
wa_qals-plnty = object_tab1-plnty.
wa_qals-plnnr = object_tab1-plnnr.
wa_qals-plnal = object_tab1-plnal.
update qals from wa_qals.
if sy-subrc <> 0.
Message E001 with 'plan is not assigned to lot in sap(updation)'.
else.
v_line = tablctrl-current_line - ( tablctrl-current_line - 1 ).
delete object_tab1.
endif.
endif.
endif.
endloop.
when 'BACK'.
leave program.
when 'NEXT'.
call screen 300.
ENDCASE.
***INCLUDE Y_RQEEAL10_USER_OK_TCF01 .
*& Form user_ok_tc
text
-->P_0078 text
-->P_0079 text
<--P_OK_CODE text
form user_ok_tc using p_tc_name type dynfnam
p_table_name
changing p_ok_code like sy-ucomm.
data: l_ok type sy-ucomm,
l_offset type i.
search p_ok_code for p_tc_name.
if sy-subrc <> 0.
exit.
endif.
l_offset = strlen( p_tc_name ) + 1.
l_ok = p_ok_code+l_offset.
case l_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_code.
endcase.
endform. " user_ok_tc
*& Form compute_scrolling_in_tc
text
-->P_P_TC_NAME text
-->P_L_OK text
form compute_scrolling_in_tc using p_tc_name
p_ok_code.
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.
assign (p_tc_name) to <tc>.
concatenate 'G_' p_tc_name '_LINES' into l_tc_lines_name.
assign (l_tc_lines_name) to <lines>.
if <tc>-lines = 0.
l_tc_new_top_line = 1.
else.
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_code
overlapping = 'X'
importing
entry_new = l_tc_new_top_line
exceptions
others = 0.
endif.
get cursor field l_tc_field_name
area l_tc_name.
if syst-subrc = 0.
if l_tc_name = p_tc_name.
set cursor field l_tc_field_name line 1.
endif.
endif.
<tc>-top_line = l_tc_new_top_line.
endform. " COMPUTE_SCROLLING_IN_TC
Thanks -
Hi,
I am asked to do bdc recording for the transaction sm30 through call transaction method. Can u please tell me how to do that...Hi Buvana,
While recording just mentioned the tcode as SM30 and then it takes you automaticcaly to that transaction code then enter the table name and press maintain tab and then select new entreis. Enter the values then save it. Press back button. Now it will take return to recording section. now u can able to see the recoding section. Generate the program automaticcaly from the recording. Now take neccessary internal tables and complete the code. Reply for any queries and reward for useful points. Take care while recording. Don't mention any wrong values.
Regards,
Kumar. -
BDC Recording for cm07 Transaction
Hi Everyone,
I'm doing BDC recording for CM07 transaction. In Recording, i need to give a print command by specifying the spool title.
For this, after opening the print window, i need to click the 'properties' button, and then select the spool title and input the value.
But I'm unable to do the recording of this print dialog box. The recording ends as soon as I give the print command.
Can anyone please tell me the solution to it.
Thanks and Regards
Rishika bawaHi,
See via transaction SHDB:
SAPLCORU_S 0100 X
BDC_OKCODE BU
AFRUD-RUECK 0000000000
AFRUD-AUFNR 100051152
AFRUD-VORNR 0010
AFRUD-LMNGA 100,000
AFRUD-MEINH PC
AFRUD-XMNGA 2,000
AFRUD-ISM01 200
AFRUD-ILE01 PC
The table for confirmations is AFRU.
Best regards,
Leandro Mengue
Maybe you are looking for
-
Search Help for custom data element
Hi experts, I have a small question regarding accessing data on different clients. Can I have an abap program where I can make reference to data /tables in different client AAA, assuming the system (AAA) with data is logically connected to the cl
-
How do you put movies on to your i pod touch
how do i put movies on to my i pod touch
-
2012 Macbook Pro 15" doesn't recognize VGA monitors plugged into displayport
We have a 2012 Macbook Pro 15" (and a 2010, and a 2011). The 2012 doesn't recognize VGA/DVI (old) monitors plugged into it, but it does recognize new DVI monitors. What gives? I'm not even sure how to diagnose or attempt to treat this. 2012 Macbook
-
Dreamweaver suddenly stopped and can't get it started anymore
While i was working with dreamweaver it all of a sudden stopped and closed. I couldn't get it to work anymore. So I restarted my computer. No luck. I tried to reinstall dreamweaver, but after 20 minutes installing it came back that it couldn't be ins
-
Just can't sync. Tryed everything.'
Just can't sync. Tryed everything.