01-11-2013 6:27 AM
hi All ,
Can any one help on this ?
i have written below code .
clear wa_final.
sort it_final by INSTID_A TYPEID_A.
LOOP AT it_final into wa_final.
idx1 = sy-tabix.
at new INSTID_A.
clear : vcount.
endat.
vcount = vcount + 1.
wa_final-Count = VCOUNT.
IF vcount gt 1.
clear : wa_final-INSTID_A, wa_final-TYPEID_A.
ENDIF.
modify it_final from wa_final index idx1.
ENDLOOP.
I'm getting Output as
INSTID_A | TYPEID_A | File Names | File Count |
Test1 | FIPP | Archiving message.DOC | 1 |
imagearchivingrippon.XLS | 2 | ||
Test.URL | 3 |
but my requirement is as shown below
INSTID_A | TYPEID_A | File Names | File Count |
Test1 | FIPP | Archiving message.DOC | 3 |
imagearchivingrippon.XLS | |||
Test.url |
It means when the maximum file count is 3 then it should display only 3 , it should not display 1 and 2.....
how can i do this by using at new ?
Regards
Smitha
01-11-2013 6:50 AM
Hi Smitha,
After
vcount = vcount + 1.
Use AT END OF INSTID_A.
wa_final-Count = VCOUNT.
ENDAT.
instead of direct pass.
Hope it will work.
Thanks,
Manireddy
01-11-2013 6:53 AM
Hi smitha,
Try this :
clear wa_final.
sort it_final by INSTID_A TYPEID_A.
LOOP AT it_final into wa_final.
idx1 = sy-tabix.
at new INSTID_A.
modify it_final from wa_final index idx2 transporting <vcount-> .
clear idx2.
idx2 = sy-tabix.
clear : vcount.
endat.
vcount = vcount + 1.
wa_final-Count = VCOUNT.
IF vcount gt 1.
clear : wa_final-INSTID_A, wa_final-TYPEID_A.
ENDIF.
*
modify it_final from wa_final index idx1 transporting <field names ><all fields except count>.
ENDLOOP.
regards
Vaibhav
01-11-2013 7:59 AM
hi Vaibhav ,
Thanks for the reply.
I'm getting the wrong output if i do this way .
Any other solution ?
Regards
Smitha
01-11-2013 8:39 AM
hi smitha
what output you are getting now ?
paste here ?
regards
vaibhav
01-11-2013 7:10 AM
01-11-2013 8:42 AM
Hi Smitha,
When you are populating IT_FINAL table, add one more field at the first position INSTTYP (which is a concatenated string of INSTID_A TYPEID_A). This is assuming that there may be a different values of TYPEID_A for INSTID_A.
For Ex:
INSTID_A | TYPEID_A | File Names | File Count |
Test1 | FIPP | Archiving message.DOC | 2 |
Test1 | FIPP | imagearchivingrippon.XLS | |
Test1 | FIPP1 | Test.URL | 1 |
Once you are ready with the table IT_FINAL, then
clear wa_final.
sort it_final by INSTTYP.
LOOP AT it_final into wa_final.
at new INSTTYP.
clear : vcount.
idx1 = sy-tabix.
endat.
vcount = vcount + 1.
wa_final-Count = VCOUNT.
IF vcount gt 1.
clear : wa_final-INSTID_A, wa_final-TYPEID_A.
ENDIF.
modify it_final from wa_final index idx1.
ENDLOOP.
Hope this will work, let us know your comments.
Thanks,
Harsha
01-11-2013 8:48 AM
Hi Smita,
If you just need the count then you can actually just use a collect statement which will give you the count based on TYPEID_A INSTID_A.
If you are gettting the output as AT NEW which is correct.
INSTID_A | TYPEID_A | File Names | File Count |
Test1 | FIPP | Archiving message.DOC | 1 |
imagearchivingrippon.XLS | 2 | ||
Test.URL | 3 |
Just after the loop is over sort the FileCount field descending.
Let me know if any additional info is required.
Thanks,
Tooshar Bendale
01-11-2013 8:51 AM
hi smitha,
i have already seen your post. When i came to reply some one has locked it. please see to the below code. i think u will get the solution. use the below code to your requirement.
TABLES : MCH1,MARA.
*************STRUCTURE FOR MCH1 TABLE********************
TYPES : BEGIN OF ty_material_detail,
matnr TYPE matnr,
charg TYPE charg_d,
END OF ty_material_detail.
*************STRUCTURE FOR FINAL TABLE*******************
TYPES : BEGIN OF ty_final,
matnr TYPE matnr,
charg TYPE charg_d,
count TYPE string,
END OF ty_final.
DATA : it_mch1 TYPE STANDARD TABLE OF ty_material_detail,
wa_mch1 TYPE ty_material_detail.
DATA : it_final_temp TYPE STANDARD TABLE OF ty_final,
wa_final TYPE ty_final.
DATA : it_final1 TYPE STANDARD TABLE OF ty_final,
wa_final1 TYPE ty_final.
DATA : gv_temp TYPE string.
DATA : gv_temp1 TYPE string.
DATA : gv_temp2 TYPE string,
flag TYPE c.
SELECT-OPTIONS : p_matnr FOR mara-matnr.
START-OF-SELECTION.
* for mch1 table
SELECT matnr charg FROM mch1 INTO TABLE it_mch1 WHERE matnr IN p_matnr.
* Sort internal table
SORT it_mch1 BY matnr.
gv_temp1 = 0.
LOOP AT it_mch1 INTO wa_mch1.
wa_final-matnr = wa_mch1-matnr.
wa_final-charg = wa_mch1-charg.
AT END OF matnr.
wa_final-count = sy-tabix.
gv_temp = wa_final-count - gv_temp1.
gv_temp1 = wa_final-count.
CLEAR wa_final-count.
wa_final-count = gv_temp.
APPEND wa_final TO it_final_temp.
CLEAR gv_temp.
ENDAT.
CLEAR wa_final.
ENDLOOP.
LOOP AT it_mch1 INTO wa_mch1.
ON CHANGE OF wa_mch1-matnr.
READ TABLE it_final_temp INTO wa_final WITH KEY matnr = wa_mch1-matnr.
wa_final1-matnr = wa_final-matnr.
wa_final1-charg = wa_final-charg.
wa_final1-count = wa_final-count.
APPEND wa_final1 TO it_final1.
CLEAR : wa_final1,wa_final.
flag = 'X'.
ENDON.
IF flag <> 'X'.
wa_final1-charg = wa_mch1-charg.
APPEND wa_final1 TO it_final1.
CLEAR : wa_final1.
ENDIF.
CLEAR flag.
ENDLOOP.
LOOP AT it_final1 INTO wa_final1.
WRITE 😕 wa_final1-matnr,wa_final1-charg,wa_final1-count.
ENDLOOP.
regards,
Rady.