11-30-2005 1:26 PM
Hi,
How can we run a loop for n nos. of records to be inserted in a table. T-Code FF67 (Screeen 2) Manual Bank Reconciliation...
Regards,
Abhishek.
11-30-2005 1:31 PM
I have no idea of LSMW but in case of a BDC,
data: t_bdcdata type standard table of BDCDATA.
data: t_messages type standard table of BDCMSGCOLL.
loop at it_records.
clear t_bdcdata.
refresh t_bdcdata.
perform fill_dynpro using <screen> <Program name>.
perform fill_fields using <fieldname> <value>.
perform fill_fields using <fieldname> <value>.
perform fill_fields using <fieldname> <value>.
.
.
.
.
.
.
call transaction 'FF67" using t_bdcdata mode 'N'
update 'S'
messages nto t_messages.
if sy-subrc = 0.
*error handling
endif.
endloop.
the part inside the loop can be obtained from the shdb recording for the FF67 transaction.
You need to copy that part of the generated code and change the values with the internal table values.
T_BDCDATA is the internal table to hold the BDC recording for each record.
T_Messages is the table to hold the messages returned from the call transaction statement.
Regards,
Ravi
11-30-2005 2:01 PM
Hi,
Use this BDC as a ref. this BDC is for MB1B.
report ZMB1B
no standard page heading line-size 255.
*include bdcrecx1.
----
Objective: BDC for transaction MB1B - Transfer Posting
*
Data is uploaded for Single plant & Storage location *
only
----
Developer: Mr. Amey Potale
Date: Nov 17, 2005
Module: ------
Last modified by: ------
----
----
Variables & Structure Declarations
----
data: begin of w_data,
werks like ikpf-werks,
lgort like ikpf-lgort,
matnr like iseg-matnr,
erfmg LIKE STPOX-MNGLG,
erfmg1(13),
end of w_data.
data : counter(2) type n.
data : fld1(20), fld2(20), l_index LIKE sy-tabix.
data : maindate(10), falg(10).
----
Internal Table Declarations
----
For capturing screen details
DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
For Storing BOM items
DATA : STB1 like STPOX OCCURS 0 WITH HEADER LINE.
For stroing item data
DATA : I_DATA LIKE W_DATA OCCURS 0 WITH HEADER LINE.
----
Start of Selection
----
start-of-selection.
IMPORT I_DATA FROM MEMORY ID 'IDATA'.
IMPORT MAINDATE FROM MEMORY ID 'MDATE'.
loop at i_data.
l_index = sy-tabix.
ON CHANGE OF I_DATA-lgort.
falg = 'True'.
perform bdc_dynpro using 'SAPMM07M' '0400'.
perform bdc_field using 'BDC_CURSOR' 'RM07M-LGORT'.
perform bdc_field using 'BDC_OKCODE' '/00'.
perform bdc_field using 'MKPF-BLDAT' MAINDATE.
perform bdc_field using 'MKPF-BUDAT' MAINDATE.
perform bdc_field using 'RM07M-BWARTWA' '311'.
perform bdc_field using 'RM07M-WERKS' '1000'.
perform bdc_field using 'RM07M-LGORT' '0002'.
perform bdc_field using 'RM07M-WVERS2' 'X'.
CLEAR fld1.
counter = 1.
endon.
perform bdc_dynpro using 'SAPMM07M' '0421'.
perform bdc_field using 'BDC_CURSOR' 'MSEG-ERFMG(01)'.
perform bdc_field using 'BDC_OKCODE' '/00'.
if ( counter eq 1 ).
perform bdc_field using 'MSEGK-UMLGO' '0001'.
endif.
CONCATENATE 'MSEG-MATNR(' counter ')' INTO fld1.
CONDENSE FLD1 NO-GAPS.
perform bdc_field using FLD1 I_DATA-MATNR.
CLEAR fld2.
CONCATENATE 'MSEG-ERFMG(' counter ')' INTO fld2.
CONDENSE FLD2 NO-GAPS.
perform bdc_field using FLD2 I_DATA-ERFMG1.
PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.
PERFORM bdc_field USING 'BDC_OKCODE' '=ENTE'.
PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.
PERFORM bdc_field USING 'BDC_OKCODE' '=ENTE'.
COUNTER = COUNTER + 1.
IF COUNTER = '05'.
PERFORM bdc_dynpro USING 'SAPMM07M' '0421'.
PERFORM bdc_field USING 'BDC_OKCODE' '=NLE'.
COUNTER = '01'.
PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.
PERFORM bdc_field USING 'BDC_OKCODE' '=ENTE'.
PERFORM bdc_field USING 'BDC_OKCODE' '/00'.
ENDIF.
AT END OF LGORT.
perform bdc_dynpro using 'SAPMM07M' '0421'.
perform bdc_field using 'BDC_CURSOR' 'MSEG-ERFMG(01)'.
perform bdc_field using 'BDC_OKCODE' '=BU'.
PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.
PERFORM bdc_field USING 'BDC_OKCODE' '=ENTE'.
PERFORM bdc_field USING 'BDC_OKCODE' '/00'.
- Call the transaction
CALL TRANSACTION 'MB1B' USING bdcdata MODE 'E' UPDATE 'S'.
ENDAT.
AT LAST.
ENDAT.
ENDLOOP.
perform close_group.
&----
*& Form bdc_dynpro
&----
text
----
-->P_0080 text
-->P_0081 text
----
FORM bdc_dynpro USING P1 P2.
BDCDATA-program = P1.
BDCDATA-DYNPRO = P2.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
CLEAR BDCDATA.
ENDFORM. " bdc_dynpro
&----
*& Form bdc_field
&----
text
----
-->P_0085 text
-->P_0086 text
----
FORM bdc_field USING F1 F2.
BDCDATA-FNAM = F1.
BDCDATA-FVAL = F2.
APPEND BDCDATA.
CLEAR BDCDATA.
ENDFORM. " bdc_field
&----
*& Form close_group
&----
text
----
--> p1 text
<-- p2 text
----
FORM close_group .
ENDFORM. " close_group
12-01-2005 5:33 AM
Hi,
Thanks for the code, it was very useful...
I have a small problem...
Now I need to put in the bdc data in second screen of ff67
This screen has a tabular fields,
-
F1 | F2 | F3 | F4 |
-
R1 - D1 | D2 | D3 | D4 |
R2 - D1 | D2 | D3 | D4 |
Rn - : | : | : | : |
-
So i need to input (D1-D4) n times..
perform bdc_field using 'FEBMKA-VGMAN(01)' W_UPLD2-VGMAN_01_011. -- This is D1 of R1
perform bdc_field using 'FEBMKA-VGMAN(02)' W_UPLD2-VGMAN_02_012. -- This is D1 of R2
So i need to concatenate 'FEBMKA-VGMAN(' <counter> ')' into fld1.
But what about VGMAN_01_011 --> D1 insertion Field
Can i use VGMAN...
viz. perform bdc_field using fld1 using W_UPLD2-VGMAN.
Here is the current sample BDC Screen2 of FF67
perform bdc_dynpro using 'SAPMF40K' '8001'.
perform bdc_field using 'BDC_CURSOR' 'FEBMKA-KWBTR(02)'.
perform bdc_field using 'BDC_OKCODE' '=SICH'.
perform bdc_field using 'FEBMKA-VGMAN(01)' W_UPLD2-VGMAN_01_011.
perform bdc_field using 'FEBMKA-VGMAN(02)' W_UPLD2-VGMAN_02_012.
perform bdc_field using 'FEBEP-VALUT(01)' W_UPLD2-VALUT_01_013.
perform bdc_field using 'FEBEP-VALUT(02)' W_UPLD2-VALUT_02_014.
perform bdc_field using 'FEBMKA-KWBTR(01)' W_UPLD2-KWBTR_01_015.
perform bdc_field using 'FEBMKA-KWBTR(02)' W_UPLD2-KWBTR_02_016.
perform bdc_field using 'FEBMKK-CHECT_KF(01)' W_UPLD2-CHECT_KF_01_017.
perform bdc_field using 'FEBMKK-CHECT_KF(02)' W_UPLD2-CHECT_KF_02_018.
perform bdc_field using 'FEBMKK-GSBER_KF(01)' W_UPLD2-GSBER_KF_01_019.
perform bdc_field using 'FEBMKK-GSBER_KF(02)' W_UPLD2-GSBER_KF_02_020.
Please Help me,
Regards,
Abhishek
11-30-2005 3:44 PM
HI,
you can run the loop in LSMW also..
in 'Maintain Field Mapping and Conversion Rules' we have options like BEGIN_OF_PROCESSING__ and __BEGIN_OF_TRANSACTION__... so you can write the loop where ever you want, even in th fileds section you can write the loop...
whatever you write in this one, the same will work as SE38 code ..
if you want to see the code you can choose the option 'Display Conversion Program'.. this will contain the code.. even you put a breakpoint and see how the code is working in the LSMW..
hope you get my point
Regards
Sudheer