‎2013 Nov 11 7:59 AM
Hi all,
i have to make a smartform for bidding, now i have written code, and creates a smartforms,
Now the problem is "as there are so many line items for which the bidding is to be done,as
shownn in screenshot, now i have to sort these line items and take unique values, for that i have
done it". Now i have to take into consideration all the unique values of "ebeln", and to print its
corresponding values in order, i have two problem to sort out, how can i sort table it_bidding
which contains the screenshot values so that it will sort according to each line item and its values,
and the second problem is that i am using A3 page to print it, in which at a single time only
three sets of ebeln can be printed, and i wants to print it as many value of ebeln exist(when first three
sets get printed next set should print on next page and so on).
I have attached two screenshot, one contains set of values while debugging, and other
contains the bidding smartforms,in which 6000000004 and 6000000005 are values of ebeln.
(In simple words i wants to segregate my smartform based on ebeln)
Here is my code snippet, which i have used to finally segregating, but its not working
FORM CALL_SMARTFORMS.
it_bidding2[] = it_bidding[].
SORT it_bidding by ebeln matnr.
SORT it_bidding2 by ebeln matnr.
DELETE ADJACENT DUPLICATES FROM it_bidding COMPARING ebeln matnr.
LOOP AT it_bidding .
wa_temp-ebeln = it_bidding-ebeln.
wa_temp-matnr = it_bidding-matnr.
wa_temp-ebelp = it_bidding-ebelp.
APPEND wa_temp to it_temp.
ENDLOOP.
* SORT it_temp by ebeln matnr.
SORT it_temp by matnr .
DATA im TYPE I.
LOOP AT it_temp into wa_temp.
delete it_temp WHERE matnr = wa_temp-matnr.
LOOP AT it_bidding2 WHERE matnr = wa_temp-matnr.
if im eq 0.
wa_bid-ebeln = it_bidding2-ebeln.
wa_bid-ebelp = it_bidding2-ebelp.
wa_bid-EMATN = it_bidding2-EMATN.
wa_bid-menge = it_bidding2-menge.
wa_bid-TXZ01 = IT_BIDDING2-txz01.
wa_bid-KTMNG = IT_BIDDING2-ktmng.
wa_bid-MEINS = IT_BIDDING2-meins.
wa_bid-NETPR = IT_BIDDING2-netpr.
wa_bid-ZWERT = IT_BIDDING2-zwert.
wa_bid-MWSKZ = IT_BIDDING2-MWSKZ.
wa_bid-FREIGHT = IT_BIDDING2-FREIGHT.
wa_bid-DIS = IT_BIDDING2-DIS.
wa_bid-EXCISE = IT_BIDDING2-EXCISE.
wa_bid-tot_amt = IT_BIDDING2-tot_amt.
wa_bid-zterm = it_bidding2-zterm.
wa_bid-angdt = it_bidding2-angdt.
wa_bid-eindt = it_bidding2-eindt.
* wa_bid-gwldt = it_bidding2-gwldt.
wa_bid-txz5 = it_bidding2-txz5.
wa_bid-txz11 = it_bidding2-txz11.
wa_bid-txz21 = it_bidding2-txz21.
wa_bid-txz31 = it_bidding2-txz31.
wa_bid-vat1 = it_bidding2-vat.
wa_bid-name1 = it_bidding2-name1.
wa_bid-telf1 = it_bidding2-telf1.
wa_bid-telf2 = it_bidding2-telf2.
wa_bid-telfx1 = it_bidding2-telfx.
wa_bid-name2 = it_bidding2-name2.
im = 1.
ELSEIF im = 1.
wa_bid-ebeln1 = it_bidding2-ebeln.
wa_bid-ebelp1 = it_bidding2-ebelp.
wa_bid-NETPR1 = IT_BIDDING2-netpr.
wa_bid-ZWERT1 = IT_BIDDING2-zwert.
wa_bid-MWSKZ1 = IT_BIDDING2-MWSKZ.
wa_bid-FREIGHT1 = IT_BIDDING2-FREIGHT.
wa_bid-DIS1 = IT_BIDDING2-DIS.
wa_bid-EXCISE1 = IT_BIDDING2-EXCISE.
wa_bid-tot_amt1 = IT_BIDDING2-tot_amt.
wa_bid-zterm1 = it_bidding2-zterm.
wa_bid-angdt1 = it_bidding2-angdt.
wa_bid-eindt1 = it_bidding2-eindt.
* wa_bid-gwldt1 = it_bidding2-gwldt.
wa_bid-txz10 = it_bidding2-txz5.
wa_bid-txz12 = it_bidding2-txz11.
wa_bid-txz32 = it_bidding2-txz31.
wa_bid-vat2 = it_bidding2-vat.
wa_bid-name11 = it_bidding2-name1.
wa_bid-telf12 = it_bidding2-telf1.
wa_bid-telf22 = it_bidding2-telf2.
wa_bid-telfx2 = it_bidding2-telfx.
wa_bid-name22 = it_bidding2-name2.
ELSEIF im = 2.
wa_bid-ebeln2 = it_bidding2-ebeln.
wa_bid-ebelp2 = it_bidding2-ebelp.
wa_bid-NETPR2 = IT_BIDDING2-netpr.
wa_bid-ZWERT2 = IT_BIDDING2-zwert.
wa_bid-MWSKZ2 = IT_BIDDING2-MWSKZ.
wa_bid-FREIGHT2 = IT_BIDDING2-FREIGHT.
wa_bid-DIS2 = IT_BIDDING2-DIS.
wa_bid-EXCISE2 = IT_BIDDING2-EXCISE.
wa_bid-tot_amt2 = IT_BIDDING2-tot_amt.
wa_bid-zterm2 = it_bidding2-zterm.
wa_bid-angdt2 = it_bidding2-angdt.
wa_bid-eindt2 = it_bidding2-eindt.
* wa_bid-gwldt2 = it_bidding2-gwldt.
wa_bid-txz15 = it_bidding2-txz5.
wa_bid-txz13 = it_bidding2-txz11.
wa_bid-txz33 = it_bidding2-txz21.
wa_bid-vat3 = it_bidding2-vat.
wa_bid-name12 = it_bidding2-name1.
wa_bid-telf13 = it_bidding2-telf1.
wa_bid-telf23 = it_bidding2-telf2.
wa_bid-telfx3 = it_bidding2-telfx.
wa_bid-name23 = it_bidding2-name2.
ENDIF.
DELETE it_bidding2 WHERE ebeln = it_bidding2-ebeln AND matnr = it_bidding2-matnr.
ENDLOOP.
APPEND wa_bid to it_bid.
im = 0.
ENDLOOP.
Please help me in sorting this problem.
‎2013 Nov 11 8:08 AM
Hi Sanjeev
Can you please rephrase your question step by step and add screen shots with some comments like this is expected or what is expected then we will be able to help you out.
As far as in case you want to print 3 lines on one page you can triger a page break inside loop end loop of table in MAIN window once the count reaches 3
Nabheet
‎2013 Nov 11 8:08 AM
Hi Sanjeev
Can you please rephrase your question step by step and add screen shots with some comments like this is expected or what is expected then we will be able to help you out.
As far as in case you want to print 3 lines on one page you can triger a page break inside loop end loop of table in MAIN window once the count reaches 3
Nabheet
‎2013 Nov 11 9:16 AM
| 6000000001 | 6000000002 | 6000000003 |
|---|---|---|
| it should contains 6000000001 related values | it should contains 6000000002 related values | it should contains 6000000003 related values |
Hello Nabheet,
thanks for your reply, let me explain it more.
as in my smartform
Let I have six line items (six materials) which I have chosen(unique values) from different values of ebeln
(in left part of the table in screenshot),
Now my requirement is that inside my table as you can see, I have three columns (6000000004,6000000005, and
Adjacent to it one more column similar to Header1, Header2 and Header3, I wants to print the corresponding values
of all line items for each different ebeln.) (in first screenshot).
Now when it will print the first three sets (6000000001, 6000000002, 6000000003), then the page should ends, and on next page the other values of ebeln (6000000004, 6000000005, and so on)should get printed, and the process continues till all the ebeln and its corresponding values gets printed.
Now as i told that i have collected all the data in it_bidding but not able to sort it as required.
(Please see my previous screenshot while debugging, i get all the values not sorted )
(as in screenshot the value of line items(material) may belongs to any or all ebeln, so my first requirement is that
the values of related fields in the table right side in screenshot should print only for those values for which it exists.).
Please tell me how could i sort it_bidding.
Let I
‎2013 Nov 11 9:26 AM
In my internal table it_bidding i have collected all the values , which can be seen in the given screenshot.
My problem is that if i will sort it by ebeln then i will loose the line items, and if i will sort it by ematn
then i wiil loose the ebeln values
So considering these situation please tell me required changes which i can perform on these.
‎2013 Nov 11 9:34 AM
Hi Sanjeev
Lets say your table IT_BIDDING contains all data. its has N number of PO's and for example 6 material.
First of all what i would have is a MAIN table which will contain material number references which needs to be printed on every page. Lets say you have 6 PO' for 6 different Material. So you will actually need 12 entries in MAIN table so that 6 lines of material are printed on each page. along 3 columns each on every page for 6 PO.
total number of main lineslv_lines = ( Number of POs / 3 ) + (Remainder in case 7 so one more) )
it_bidding_t[] = it_bidding[].
sort it_bidding_t by matnr.
delete adjacent duplicates from IT_BIIDING_T comparing matnr.
DO lv_lines times.
loop at IT_BIIDING_T.
append it_bidding to it_bidding1.
endloop.
enddo.
So IT_BIDDING1 has you number of times material has to be printed on each page.
Your main loop will start on this.
For each material you will read IT_BIDDING to read PO number. once it is printed you will mark it as X (a flag field to understand it has been printed.)
And after every 6 lines of IT_BIDDING1 a page break.
Hope it gives you some directiona bout the idea.
‎2013 Nov 11 9:35 AM
Use temporary table to sort and keep the main data in IT_BIDDING
‎2013 Nov 11 9:55 AM
Dear Sanjeev Kumar,
There is a simple solution for this.
Loop your internal table and update a counter value. Call the smartform once the counter reaches 3.
And outside the loop, check the counter again just in case if the final counter end up in a value less than 3.
Here I give you an example.
LOOP AT it_final INTO wa_final.
v_count = v_count + 1.
IF v_count EQ 1.
tag1-butxt = wa_final-butxt.
tag1-name1 = wa_final-name1.
tag1-matnr = wa_final-matnr.
tag1-lgort = wa_final-lgort.
tag1-lgpbe = wa_final-lgpbe.
tag1-bismt = wa_final-bismt.
tag1-meins = wa_final-meins.
tag1-maktx = wa_final-maktx.
tag1-charg = wa_final-charg.
tag1-clabs = wa_final-clabs.
CLEAR wa_final.
ENDIF.
IF v_count EQ 2.
tag2-butxt = wa_final-butxt.
tag2-name1 = wa_final-name1.
tag2-matnr = wa_final-matnr.
tag2-lgort = wa_final-lgort.
tag2-lgpbe = wa_final-lgpbe.
tag2-bismt = wa_final-bismt.
tag2-meins = wa_final-meins.
tag2-maktx = wa_final-maktx.
tag2-charg = wa_final-charg.
tag2-clabs = wa_final-clabs.
CLEAR wa_final.
ENDIF.
IF v_count EQ 3.
tag3-butxt = wa_final-butxt.
tag3-name1 = wa_final-name1.
tag3-matnr = wa_final-matnr.
tag3-lgort = wa_final-lgort.
tag3-lgpbe = wa_final-lgpbe.
tag3-bismt = wa_final-bismt.
tag3-meins = wa_final-meins.
tag3-maktx = wa_final-maktx.
tag3-charg = wa_final-charg.
tag3-clabs = wa_final-clabs.
CLEAR wa_final.
ENDIF.
IF v_count EQ 4.
tag4-butxt = wa_final-butxt.
tag4-name1 = wa_final-name1.
tag4-matnr = wa_final-matnr.
tag4-lgort = wa_final-lgort.
tag4-lgpbe = wa_final-lgpbe.
tag4-bismt = wa_final-bismt.
tag4-meins = wa_final-meins.
tag4-maktx = wa_final-maktx.
tag4-charg = wa_final-charg.
tag4-clabs = wa_final-clabs.
CLEAR wa_final.
ENDIF.
IF v_count EQ 5.
tag5-butxt = wa_final-butxt.
tag5-name1 = wa_final-name1.
tag5-matnr = wa_final-matnr.
tag5-lgort = wa_final-lgort.
tag5-lgpbe = wa_final-lgpbe.
tag5-bismt = wa_final-bismt.
tag5-meins = wa_final-meins.
tag5-maktx = wa_final-maktx.
tag5-charg = wa_final-charg.
tag5-clabs = wa_final-clabs.
CLEAR wa_final.
ENDIF.
IF v_count EQ 6.
tag6-butxt = wa_final-butxt.
tag6-name1 = wa_final-name1.
tag6-matnr = wa_final-matnr.
tag6-lgort = wa_final-lgort.
tag6-lgpbe = wa_final-lgpbe.
tag6-bismt = wa_final-bismt.
tag6-meins = wa_final-meins.
tag6-maktx = wa_final-maktx.
tag6-charg = wa_final-charg.
tag6-clabs = wa_final-clabs.
CLEAR wa_final.
ENDIF.
IF v_count EQ 7.
tag7-butxt = wa_final-butxt.
tag7-name1 = wa_final-name1.
tag7-matnr = wa_final-matnr.
tag7-lgort = wa_final-lgort.
tag7-lgpbe = wa_final-lgpbe.
tag7-bismt = wa_final-bismt.
tag7-meins = wa_final-meins.
tag7-maktx = wa_final-maktx.
tag7-charg = wa_final-charg.
tag7-clabs = wa_final-clabs.
CLEAR wa_final.
ENDIF.
IF v_count EQ 8.
tag8-butxt = wa_final-butxt.
tag8-name1 = wa_final-name1.
tag8-matnr = wa_final-matnr.
tag8-lgort = wa_final-lgort.
tag8-lgpbe = wa_final-lgpbe.
tag8-bismt = wa_final-bismt.
tag8-meins = wa_final-meins.
tag8-maktx = wa_final-maktx.
tag8-charg = wa_final-charg.
tag8-clabs = wa_final-clabs.
CLEAR wa_final.
ENDIF.
IF v_count EQ 9.
tag9-butxt = wa_final-butxt.
tag9-name1 = wa_final-name1.
tag9-matnr = wa_final-matnr.
tag9-lgort = wa_final-lgort.
tag9-lgpbe = wa_final-lgpbe.
tag9-bismt = wa_final-bismt.
tag9-meins = wa_final-meins.
tag9-maktx = wa_final-maktx.
tag9-charg = wa_final-charg.
tag9-clabs = wa_final-clabs.
CLEAR wa_final.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZMM_LABLE_PRINT_MAT_STCK'
IMPORTING
fm_name = v_fm_name.
CALL FUNCTION v_fm_name
EXPORTING
control_parameters = w_cparam
tag1 = tag1
tag2 = tag2
tag3 = tag3
tag4 = tag4
tag5 = tag5
tag6 = tag6
tag7 = tag7
tag8 = tag8
tag9 = tag9.
CLEAR : v_count, tag1, tag2, tag3, tag4, tag5, tag6, tag7, tag8, tag9.
ENDIF.
ENDLOOP.
IF NOT v_count IS INITIAL.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZMM_LABLE_PRINT_MAT_STCK'
IMPORTING
fm_name = v_fm_name.
CALL FUNCTION v_fm_name
EXPORTING
control_parameters = w_cparam
tag1 = tag1
tag2 = tag2
tag3 = tag3
tag4 = tag4
tag5 = tag5
tag6 = tag6
tag7 = tag7
tag8 = tag8
tag9 = tag9.
ENDIF.
Hope this helps.
Thanks and Regards
Davis
‎2013 Nov 11 10:06 AM
Dear Nabheet,
i am not getting these lines as sujjested by you, how can i calculate lv_lines.
Please explain it. through code snippet (for remainder).
Because i have calculated no of PO in it_bidding through TLINES.
total number of main lines
lv_lines = ( Number of POs / 3 ) + (Remainder in case 7 so one more) )
‎2013 Nov 11 10:14 AM
Hi Davis,
how could you assign each line items with its correponding values of PO,
means in my internal table it_bidding i have recurring PO and the problem lies
in sorting it so that i can get specific PO with its corresponding related values.
Please see the screenshot, and then tell me the solution
‎2013 Nov 11 10:18 AM
My idea is since each page will have the same materials right..
You have two options one as suggested above
IT_BIDDING contains all data with an addtional field MARK( to flag if PO has been printed).
IT_BIDDING1 = IT_BIDDING.
SORT IT_BIDDING1 BY MATNR.
DELETE ADJACENT DUPLICATES FROM IT_BIDDING1 COMPARING MATNR.
IT_BIDDING2 = IT_BIDDING.
SORT IT_BIDDING2 BY EBELN.
DELETE ADJACENT DUPLICATES FROM IT_BIDDING2 COMPARING EBELN.
DESCRIBE TABLE IT_BIDDING2 LINES LV_LINES.
"Since each page can have 3 po's.
LV_TOT_TIME(times smartform will be called)
LV_TOT_TIME = ( (LV_LINES/3) + LV_LINES MOD 3 ).
DO LV_TOT_TIME
( MARK THE PO'S DETAIL WHICH ARE SENT IN THIS CALL. )
CALL SMARTFORM
ENDSMARTFORM.
Second way you call smartform once and inside smartform in initialization you haven
DO LV_TOT_TIME.
LOOP AT IT_BIDDING1
APPEND IT_BIDDING1 TO IT_BIDDING3 " since 6 lines have to printed on each page and lets say we have
" 3 pages to be printed so we need 18 lines so that table containue the loop.
ENDLOOP.
Then
LOOP AT IT_BIDDING 3.
READ TABLE IT_BIDDING FOR MATNR TO GET EBELN DETAILS. Set the flag MARK so that next time you dont print it again
ENDDO
‎2013 Nov 11 10:23 AM
Dear Sanjeev Kumar,
Have a temporary internal table for holding the value of line items for 3 PO.
Once 3 PO is processed with its line items, call the smartform and display it contents.
Refresh the contents of the temporary internal table and append the values of next 3 PO with its line items.
Hope this will help. If you need more help, please let me know
‎2013 Nov 11 10:36 AM
Dear Davis,
you are not getting my points, my question is untill i get my data in sorted form, i am not able to do what you have sujjested, please elaborate it that how could i sort my internal table it_bidding
such that all the PO with its line items will have a unique values, then only i can do as you have sujjested.
‎2013 Nov 11 10:38 AM
‎2013 Nov 11 11:57 AM
Dear Nabheet,
according to you now i have written these lines of code ,
in which i am getting unique PO no, but by sorting and deleting i looses line items, so how
will i match line item wise with main internal table it_bidding.
and if i sort and delete with ebeln ebelp, then i think it has not any advantage, the problem is still
not solved because in it_bidding5 if i will sort it by ebeln only, then i will looses line item .
Please tell me what can i do.
it_bidding1 = it_bidding .
SORT IT_BIDDING1 by ematn.
DELETE ADJACENT DUPLICATES FROM it_bidding1 COMPARING ematn.
it_bidding5[] = it_bidding[].
SORT it_bidding5 BY ebeln.
DELETE ADJACENT DUPLICATES FROM it_bidding5 COMPARING ebeln.
DESCRIBE TABLE it_bidding5 LINES LV_LINES.
LV_TOT_TIME = ( ( LV_LINES / 3 ) + LV_LINES MOD 3 ).
DO LV_TOT_TIME TIMES.
PERFORM CALL_SMARTFORMS.
ENDDO.
‎2013 Nov 11 12:05 PM
One small question lets say you have a mterial belonging to one PO but two different line item how will your output looks like?
‎2013 Nov 11 1:22 PM
Dear Nabheet,
materials are itself a line item, so a PO may have one or more materials as line item but we have to consider the unique materials
among all PO's.
and based on these unique materials i have to check that for a single materilal which PO have its
corresponding values....and these values should get printed in front of respective PO's.
for which i have written these code but not getting how to fetch respective values.
in it_bidding1 i get unique values of ematn, but in table it_bidding5 i gets values as shown in screenshot,
and my requirement i have told you that for each PO , if it has a materila among line items material then
its value should gets printed , otherwise it kept blank (e.g. if PO 6000000003 contains line item 20 then
it should print otherwise kept its field blank, and it only prints for those PO having a line item 20)
Hoping any good solution from your side.
it_bidding1[] = it_bidding[] .
SORT IT_BIDDING1 by ematn.
DELETE ADJACENT DUPLICATES FROM it_bidding1 COMPARING ematn.
it_bidding5[] = it_bidding[].
SORT it_bidding5 BY ebeln ebelp.
DELETE ADJACENT DUPLICATES FROM it_bidding5 COMPARING ebeln ebelp.
DATA : im TYPE i.
LOOP AT it_bidding1 INTO wa_bidding1.
DELETE it_bidding1 WHERE ematn = wa_bidding1-ematn.
LOOP AT it_bidding5 WHERE ematn = wa_bidding1-ematn.
(just tell me how can i loop here so that i will get unique set of values for each PO. )
DELETE it_bidding5 WHERE ebeln = it_bidding5-ebeln AND ematn = it_bidding5-ematn.
ENDLOOP.
APPEND wa_bid to it_bid.
im = 0.
ENDLOOP.
‎2013 Nov 11 2:05 PM
Here is the simple solution
IT_BID-->Contains all data
IT_BID1--> Unqiue Material
IT_BID2--> Unqiue PO only.
IT_BID2_TEMP--> Currently processed PO's
while (LV_FLAG ne 'X).
LOOP AT IT_BID2.
IF SY-TABIX = 4.
EXIT.
ENDIF.
DELETE IT_BID2 INDEX SY-TABIX" DELETE THE po as it is being sent for display
APPEND IT_BID2 TO IT_BID2_TEMP." To be passed to smartform current set maximum of 3 PO's.
ENDLOOP.
IF SY-SUBRC NE 0.
LV_FLAG = 'X'. " NO PO'S LEFT TO BE PROCESSD "
ENDIF.
CALL SMARTFORM WITH IT_BID,IT_BID1 AND IT_BID2_TEMP.
Smartform coding
for each line of IT_BID1(MAIN table)
Read table it_bid2_temp index 1. To get first PO number whose detail to be printed.
bsaed on PO number from IT_BID2_TEMP and material from IT_BID1
read the detail from IT_BID.
Read table it_bid2_temp index 2. To get second PO number whose detail to be printed.
bsaed on PO number from IT_BID2_TEMP and material from IT_BID1
read the detail from IT_BID.
Read table it_bid2_temp index 3 To get third PO number whose detail to be printed.
bsaed on PO number from IT_BID2_TEMP and material from IT_BID1
read the detail from IT_BID.
ENDWHILE.
hope its clear now
‎2013 Nov 12 8:09 AM
Dear Nabheet,
as per as your instruction i have changed my code as shown below
(it_bidding contains all data).
Now according to you
it_bidding2[] = it_bidding[].
SORT it_bidding2 BY ematn.
DELETE ADJACENT DUPLICATES FROM it_bidding2 COMPARING ematn.
it_bidding5[] = it_bidding[].
SORT it_bidding5 BY ebeln.
DELETE ADJACENT DUPLICATES FROM it_bidding5 COMPARING ebeln.
WHILE LV_FLAG NE 'X'.
LOOP AT it_bidding5.
IF SY-SUBRC = 4.
EXIT.
ENDIF.
DELETE it_bidding5 INDEX sy-tabix.
APPEND it_bidding5 TO it_bid2_temp.
ENDLOOP.
IF SY-SUBRC NE 0.
LV_FLAG = 'X'.
ENDIF.
PERFORM CALL_SMARTFORMS.
FORM CALL_SMARTFORMS.
DATA : TLINES TYPE I.
DESCRIBE TABLE it_bid LINES TLINES.
IF TLINES GT 2.
sform = 'ZST_MM_SF_PURCHASE1'.
ELSE.
sform = 'ZST_MM_SF_PURCHASE'.
ENDIF.
*ENDLOOP.
EXPORT it_bid FROM it_bid TO MEMORY ID 'ZZ_BID'.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = sform
* VARIANT = ' '
* DIRECT_CALL = ' '
IMPORTING
FM_NAME = fname
* EXCEPTIONS
* NO_FORM = 1
* NO_FUNCTION_MODULE = 2
* OTHERS = 3
.
IF SY-SUBRC <> 0.
ENDIF.
CALL FUNCTION fname
TABLES
it_head = it_head
it_bidding1 = it_bidding1
it_bidding = it_bidding.
it_bidding2 = it_bidding2.
it_bid2_temp = it_bid2_temp.
IF sy-subrc <> 0.
ENDIF.
ENDFORM.
Now according to you, i have to write these code lines inside smartform or inside calling of my smartform ?
Please clear it, thanks a lot in advance
Smartform coding
for each line of IT_BID1(MAIN table)
Read table it_bid2_temp index 1. To get first PO number whose detail to be printed.
bsaed on PO number from IT_BID2_TEMP and material from IT_BID1
read the detail from IT_BID.
Read table it_bid2_temp index 2. To get second PO number whose detail to be printed.
bsaed on PO number from IT_BID2_TEMP and material from IT_BID1
read the detail from IT_BID.
Read table it_bid2_temp index 3 To get third PO number whose detail to be printed.
bsaed on PO number from IT_BID2_TEMP and material from IT_BID1
read the detail from IT_BID.
‎2013 Nov 12 8:13 AM
This has to be written in smartform. But call oif smartform should be in while loop. Seconldy
LOOP AT it_bidding5.
IF SY-TABIX = 4.
EXIT.
ENDIF.
DELETE it_bidding5 INDEX sy-tabix.
APPEND it_bidding5 TO it_bid2_temp.
ENDLOOP.
‎2013 Nov 12 9:51 AM
Dear Nabheet,
thanks a lot for your support, but i have a major problem in which i am struggling till now.
In it_bidding i have many data, i kept it to copy in different internal tables.
For unique material it_bidding2,
it_bidding5 for unique PO and it_bid2_temp for currently processed PO having unique PO (as you have sujjested).
Now the Problem lies in matching data between these sorted internal tables,the main table it_bidding have many data (SEE SCREENSHOT) ,it_bidding2 have unique material, it_bidding5(in screenshot for it_bid2_temp) have unique PO but don't have all the material (a few materials).
So when i have used this query it bypasses the loop.
Please sujjest me after seeing all the screenshot what can i do
(if i want to read it_bidding having all data, it is not working).
Here is the code i have written inside my smartform.
READ TABLE IT_BID2_TEMP INDEX 1.
LOOP AT IT_BIDDING INTO WA_BIDDING WHERE EMATN = WA_BID2_TEMP-EMATN
AND EBELN = WA_BID2_TEMP-EBELN.
IF SY-SUBRC = 0.
wa_bid-ebeln = it_bidding-ebeln.
wa_bid-ebelp = it_bidding-ebelp.
wa_bid-EMATN = it_bidding-EMATN.
wa_bid-menge = it_bidding-menge.
wa_bid-TXZ01 = IT_BIDDING-txz01.
wa_bid-KTMNG = IT_BIDDING-ktmng.
wa_bid-MEINS = IT_BIDDING-meins.
wa_bid-NETPR = IT_BIDDING-netpr.
wa_bid-ZWERT = IT_BIDDING-zwert.
wa_bid-MWSKZ = IT_BIDDING-MWSKZ.
wa_bid-FREIGHT = IT_BIDDING-FREIGHT.
wa_bid-DIS = IT_BIDDING-DIS.
wa_bid-EXCISE = IT_BIDDING-EXCISE.
wa_bid-tot_amt = IT_BIDDING-tot_amt.
wa_bid-zterm = it_bidding-zterm.
wa_bid-angdt = it_bidding-angdt.
wa_bid-eindt = it_bidding-eindt.
* wa_bid-gwldt = it_bidding2-gwldt.
wa_bid-txz5 = it_bidding-txz5.
wa_bid-txz11 = it_bidding-txz11.
wa_bid-txz21 = it_bidding-txz21.
wa_bid-txz31 = it_bidding-txz31.
wa_bid-vat1 = it_bidding-vat.
wa_bid-name1 = it_bidding-name1.
wa_bid-telf1 = it_bidding-telf1.
wa_bid-telf2 = it_bidding-telf2.
wa_bid-telfx1 = it_bidding-telfx.
wa_bid-name2 = it_bidding-name2.
ENDIF.
ENDLOOP.
‎2013 Nov 12 10:31 AM
IT_BID2_TEMP shall have 3 PO at one time becoz you are printing 3 po's.
Change this code
READ TABLE IT_BID2_TEMP INDEX 1.
LOOP AT IT_BIDDING INTO WA_BIDDING WHERE EMATN = IT_BID2_TEMP-EMATN
AND EBELN = IT_BID2_TEMP-EBELN.
use WA_BIDDING here as the value will be in work area
wa_bid-ebeln = it_bidding-ebeln.
wa_bid-ebelp = it_bidding-ebelp.
wa_bid-EMATN = it_bidding-EMATN.
wa_bid-menge = it_bidding-menge.
wa_bid-TXZ01 = IT_BIDDING-txz01.
wa_bid-KTMNG = IT_BIDDING-ktmng.
wa_bid-MEINS = IT_BIDDING-meins.
wa_bid-NETPR = IT_BIDDING-netpr.
wa_bid-ZWERT = IT_BIDDING-zwert.
wa_bid-MWSKZ = IT_BIDDING-MWSKZ.
wa_bid-FREIGHT = IT_BIDDING-FREIGHT.
wa_bid-DIS = IT_BIDDING-DIS.
wa_bid-EXCISE = IT_BIDDING-EXCISE.
wa_bid-tot_amt = IT_BIDDING-tot_amt.
wa_bid-zterm = it_bidding-zterm.
wa_bid-angdt = it_bidding-angdt.
wa_bid-eindt = it_bidding-eindt.
* wa_bid-gwldt = it_bidding2-gwldt.
wa_bid-txz5 = it_bidding-txz5.
wa_bid-txz11 = it_bidding-txz11.
wa_bid-txz21 = it_bidding-txz21.
wa_bid-txz31 = it_bidding-txz31.
wa_bid-vat1 = it_bidding-vat.
wa_bid-name1 = it_bidding-name1.
wa_bid-telf1 = it_bidding-telf1.
wa_bid-telf2 = it_bidding-telf2.
wa_bid-telfx1 = it_bidding-telfx.
wa_bid-name2 = it_bidding-name2.
ENDLOOP.
‎2013 Nov 12 11:13 AM
Dear Nabheet,
it_bid2_temp does not have all the materials it contains only unique PO, so if i will take
LOOP AT IT_BIDDING INTO WA_BIDDING WHERE EMATN= IT_BID2_TEMP-EMATN
AND EBELN = IT_BID2_TEMP-EBELN
then it will fetch only those values for which it finds ebeln and ematn, so my problem lies in this
How it will fetch for all ematn values......?
‎2013 Nov 12 11:22 AM
Sanjeev
You have your loop on table IT_BID1 in smartform which has unique material. It will process each record one by one.
So first time when material M1 is processed you just have to put in those details not for other materials as that will be printed in second iteration when unique material M2 comes
‎2013 Nov 13 8:00 AM
Dear Nabheet,
thanks a lot for your sujjestions, i have worked on your way but one problem is there
according to you to segregate it based on 3 PO you told to use following code lines
(it_bid contains my data based on ebeln), but LV_LINES gives no. of rows not no. of columns,
and i don't want it, if i have to segregate it based on PO i must calculate no. of columns of table.
Can you please tell me what code should i have to write, and within DO...ENDDO, i have to call
my smartform ?
DESCRIBE TABLE it_bid LINES LV_LINES.
LV_TOT_TIME = ( ( LV_LINES / 3 ) + LV_LINES MOD 3 ).
DO LV_TOT_TIME TIMES.
ENDDO.
‎2013 Nov 13 8:06 AM
Sanjeev on each page you will show 3 PO's right.
let us assume IT_BID has 7 PO's unique one. So you need to print three page with 3 PO's on first two page and one on last. For each call of smartform you are passing 3 PO and unique material. In our case we need to call it 3 times right.
lv_tot_time = 7/3 + 7%3 which give us 3 times.
So you have to call your smartform 3 times. During first you will pass first set of 3 PO's in next another 3 and in last only 1 which is left
I hope its clear now.
‎2013 Nov 14 5:40 AM
Dear Nabheet,
i have done as you have sujjested, here is my smartform.
Please see whats wrong with it because i am getting data only for a single material six time.
But it should come to be for six different material .
‎2013 Nov 14 5:50 AM
Your main loop should be on table which has unqiue material number lets say IT_BID.
Then IT_BID1 has unique PO's. so in first column where first PO is displayed you READ IT_BID1 index 1.
based on this IT_BID1-EBELN and IT_BID-MATNR you read the data from IT_BID2(it has all data).
So by looping at IT_BID(unqiue material) each time you will have different material with corresponding data.
Nabheet
‎2013 Nov 15 4:48 AM
Thanks a Lot Nabheet for your support, here i am rewarding your answer as correct answer.
Once again a lots of thanks
‎2013 Nov 15 4:57 AM
‎2013 Nov 15 5:27 AM
Dear Nabheet,
thanks a lot for helping me, i little thing is that while loopping i am getting almost data,
but while modifying and transporting i didn't get all those data, like i have to set each ebeln
and its corresponding values at table header, while looping i gets all those data, but when i
have modified it and tranported, then only i am getting last 2 set of values for ebeln and its corresponding data(like vendor name, tel. no etc,).
Now i have kept my smartform to hold four sets of data(previously it was two).
So whay it is not transporting first two sets of data.
Can you please tell me whats the problem......?
‎2013 Nov 15 6:03 AM
‎2013 Nov 15 6:46 AM
| No Data | No Data | Ebeln3 | Ebeln4 |
|---|---|---|---|
| data for ebeln1 | data for ebeln2 | data for ebeln3 | data for ebeln4 |
| data for ebeln1 | data for ebeln2 | data for ebeln3 | data for ebeln4 |
| data for ebeln1 | data for ebeln2 | data for ebeln3 | data for ebeln4 |
| data for ebeln1 | data for ebeln2 | data for ebeln3 | data for ebeln4 |
Yes Nabheet,
i have to show 4 PO and its Corresponding values as i stated previously in each page.
But it is not showing each PO, only showing last 2 PO and its corresponding values(in table header),
i have changed it as shown below but it is still showing 2 PO, but providing material
details for 4 PO, i think i am looping for material in main loop, so its showing true values
for 4 PO in first page, but i am not able to show 4 PO deatils(Name, Tel No. etc on first page as table heading).
In simple words, i am showing data for 4 PO on first page because i have loop based on material
as line items, but not able to show all the 4 PO on header.
WHILE LV_FLAG NE 'X'.
LOOP AT it_bidding5.
IF SY-TABIX = 5.
EXIT.
ENDIF.
DELETE it_bidding5 INDEX sy-tabix.
APPEND it_bidding5 TO it_bid2_temp.
ENDLOOP.
IF SY-SUBRC NE 0.
LV_FLAG = 'X'.
ENDIF.
PERFORM CALL_SMARTFORMS.
ENDWHILE.
DESCRIBE TABLE it_bidding5 LINES LV_LINES.
LV_TOT_TIME = ( ( LV_LINES / 4 ) + LV_LINES MOD 4 ).
DO LV_TOT_TIME TIMES.
ENDDO.
‎2013 Nov 15 7:06 AM
During the first call to smartform you should pass 4 PO number . all unique material and all data. Check in debugging what are you passing. Plus did you modify those READ tbale index1,2,3 also?
A small change in formula
if lv_lines mod 4 eq 0.
lv_extra = 0.
else.
lv_extra = 1.
endif.
LV_TOT_TIME = ( ( LV_LINES / 4 ) + lv_extra
‎2013 Nov 15 7:06 AM
During the first call to smartform you should pass 4 PO number . all unique material and all data. Check in debugging what are you passing. Plus did you modify those READ tbale index1,2,3 also?
A small change in formula
if lv_lines mod 4 eq 0.
lv_extra = 0.
else.
lv_extra = 1.
endif.
LV_TOT_TIME = ( ( LV_LINES / 4 ) + lv_extra
‎2013 Nov 15 7:32 AM
Dear Nabheet,
here is my code for first index, yes i am passing 4 PO at once,
if i am using Modify READ TABLE than i have to use single variables in each ebeln,
(its giving error for different variables that it doesn't exist in read table, which is obvious)
but i have read table and kept each ebeln's line item in a separate variables.
like netpr1, netpr2.....
Same code has been done for other 3 index separately, but it is somewhat loosing first 2 ebeln.
LOOP AT IT_BID INTO WA_BID.
READ TABLE IT_BID2_TEMP INDEX 1.
LOOP AT IT_BIDDING INTO WA_BIDDING WHERE EBELN = IT_BID2_TEMP-EBELN
AND EMATN = WA_BID-EMATN.
IF SY-SUBRC = 0.
wa_bid-ebeln = wa_bidding-ebeln.
wa_bid-ebelp = wa_bidding-ebelp.
wa_bid-NETPR = wa_BIDDING-netpr.
wa_bid-ZWERT = wa_BIDDING-zwert.
wa_bid-MWSKZ = wa_BIDDING-MWSKZ.
wa_bid-FREIGHT = wa_BIDDING-FREIGHT.
wa_bid-DIS = wa_BIDDING-DIS.
wa_bid-EXCISE = wa_BIDDING-EXCISE.
wa_bid-tot_amt = wa_BIDDING-tot_amt.
wa_bid-zterm = wa_bidding-zterm.
wa_bid-angdt = wa_bidding-angdt.
wa_bid-eindt = wa_bidding-eindt.
* wa_bid-gwldt = it_bidding2-gwldt.
wa_bid-txz5 = wa_bidding-txz5.
wa_bid-txz11 = wa_bidding-txz11.
wa_bid-txz21 = wa_bidding-txz21.
wa_bid-txz31 = wa_bidding-txz31.
wa_bid-vat1 = wa_bidding-vat.
wa_bid-name1 = wa_bidding-name1.
wa_bid-telf1 = wa_bidding-telf1.
wa_bid-telf2 = wa_bidding-telf2.
wa_bid-telfx1 = wa_bidding-telfx.
wa_bid-name2 = wa_bidding-name2.
MODIFY IT_BID FROM wa_bid TRANSPORTING EBELN EBELP NETPR ZWERT
MWSKZ FREIGHT DIS EXCISE TOT_AMT ZTERM ANGDT EINDT TXZ5 TXZ11
TXZ21 TXZ31 NAME1 NAME2 TELF1 TELF2 TELFX1 VAT1.
ENDIF.
ENDLOOP.
ENDLOOP.
‎2013 Nov 15 7:44 AM
Sanjeev
Do we have the assumption for every unqiue material we will get only one po line item if yes. then change as below
LOOP AT IT_BID INTO WA_BID.
LV_TABIX = SY-TABIX.
READ TABLE IT_BID2_TEMP INDEX 1.
LOOP AT IT_BIDDING INTO WA_BIDDING WHERE EBELN = IT_BID2_TEMP-EBELN
AND EMATN = WA_BID-EMATN.
IF SY-SUBRC = 0.
wa_bid-ebeln = wa_bidding-ebeln.
wa_bid-ebelp = wa_bidding-ebelp.
wa_bid-NETPR = wa_BIDDING-netpr.
wa_bid-ZWERT = wa_BIDDING-zwert.
wa_bid-MWSKZ = wa_BIDDING-MWSKZ.
wa_bid-FREIGHT = wa_BIDDING-FREIGHT.
wa_bid-DIS = wa_BIDDING-DIS.
wa_bid-EXCISE = wa_BIDDING-EXCISE.
wa_bid-tot_amt = wa_BIDDING-tot_amt.
wa_bid-zterm = wa_bidding-zterm.
wa_bid-angdt = wa_bidding-angdt.
wa_bid-eindt = wa_bidding-eindt.
* wa_bid-gwldt = it_bidding2-gwldt.
wa_bid-txz5 = wa_bidding-txz5.
wa_bid-txz11 = wa_bidding-txz11.
wa_bid-txz21 = wa_bidding-txz21.
wa_bid-txz31 = wa_bidding-txz31.
wa_bid-vat1 = wa_bidding-vat.
wa_bid-name1 = wa_bidding-name1.
wa_bid-telf1 = wa_bidding-telf1.
wa_bid-telf2 = wa_bidding-telf2.
wa_bid-telfx1 = wa_bidding-telfx.
wa_bid-name2 = wa_bidding-name2.
MODIFY IT_BID INDEX LV_TABIX FROM wa_bid TRANSPORTING EBELN EBELP NETPR ZWERT
MWSKZ FREIGHT DIS EXCISE TOT_AMT ZTERM ANGDT EINDT TXZ5 TXZ11
TXZ21 TXZ31 NAME1 NAME2 TELF1 TELF2 TELFX1 VAT1.
ENDIF.
ENDLOOP.
ENDLOOP.
‎2013 Nov 15 8:03 AM
Dear Nabheet,
nothing changes.........
Output is as before it was
‎2013 Nov 15 8:10 AM
‎2013 Nov 15 8:32 AM
Try to Concatenate two field value ebeln+ematn and make one Field ( suppose , a temp_field) and then sort your table based on this temp_field .
Regard's
Smruti
‎2013 Nov 15 9:43 AM
Dear Nabheet,
please see the screenshot, while i am getting right hand side values for ebeln 6000000004 and 6000000005
and its related values in table header, but i am not getting it in left side for 6000000002 and 6000000003
in left hand side.