‎2013 Nov 28 5:05 AM
HI,
when I use collect statement ,the interlnal table add an extra row ...:
I want only 16 in fking not 8
8
16
‎2013 Nov 28 5:09 AM
‎2013 Nov 28 5:09 AM
‎2013 Nov 28 5:20 AM
select
zprs_role
fkimg
vbeln
ZPRS_OFFSHORE
ps_psp_pnr
arktx
posnr
netwr
from vbrp into corresponding fields of table it_tab
where vbeln = wa_vbrk-vbeln.
loop at it_role into wa_role.
collect wa_role into it_tab.
* read table it_tab into wa_tab index sy-index.
endloop.
ypes: begin of ty_tab,
zprs_role type vbrp-zprs_role,
fkimg type vbrp-fkimg,
fkdat type vbrk-fkdat,
knumv type vbrk-knumv,
kawrt type konv-kawrt,
ZPRS_OFFSHORE type vbrp-ZPRS_OFFSHORE,
ps_psp_pnr type vbrp-ps_psp_pnr,
post1 type prps-post1,
arktx type vbrp-arktx,
posnr type vbrp-posnr,
netwr type vbrp-netwr,
vbeln type vbrp-vbeln,
end of ty_tab.
‎2013 Nov 28 5:21 AM
elect
zprs_role
fkimg
vbeln
ZPRS_OFFSHORE
ps_psp_pnr
arktx
posnr
netwr
from vbrp into corresponding fields of table it_tab
where vbeln = wa_vbrk-vbeln.
loop at it_role into wa_role.
collect wa_role into it_tab.
* read table it_tab into wa_tab index sy-index.
endloop.
delete it_itab where zprs_role = ''
‎2013 Nov 28 5:28 AM
‎2013 Nov 28 5:33 AM
loop at it_role into wa_role.
Move-corresponding wa_role to wa_role1.
collect wa_role1 to it_role1.
endloop.
Philip.
‎2013 Nov 28 5:56 AM
1. You are using the same table to retrieve the data using select statement and in the collect statement
The first two records are retrieved from the select statement, it is not coming from the collect statement. Its only the last record that is coming from the collect statement. So the collect statement is working fine, resulting in just one record having the total 16.
2. When using collect statement, the structure of it_role and the table you are collecting to must be same.
TYPES: BEGIN OF t_collect,
zprs_role type vbrp-zprs_role,
fkimg TYPE vbrp-fkimg,
END OF t_collect.
DATA: it_roles TYPE STANDARD TABLE OF t_collect, wa_roles type t_collect.
data : it_collect type TABLE OF t_collect.
loop at it_itab into wa_itab.
move-corresponding wa_itab to wa_roles.
APPEND wa_roles to it_roles.
endloop.
sort it_roles by zprs_role.
loop at it_roles into wa_roles.
collect wa_roles into it_collect.
endloop.
‎2013 Nov 28 5:57 AM
Use separate tables for select statement and collect statement..
‎2013 Nov 28 6:03 AM
Hi,
If your requirement is to delete the duplicate entries you can go for this,
DELETE ADJACENT DUPLICATES FROM it_itab COMPARING zprs_role fkimg.
Regards,
Anoop
‎2013 Nov 28 6:09 AM
OK Susmitha......I got it.........now ZPRS_OFFSHORE value is 0 and 1...but instade of 0 and 1 ihave to display domain fixed vale OFF and ON
‎2013 Nov 28 6:17 AM
To get the domain, use the following FM.
DATA :it_taba TYPE STANDARD TABLE OF dd07v WITH HEADER LINE,
it_tabb TYPE STANDARD TABLE OF dd07v.
CLEAR :it_taba, it_tabb.
CALL FUNCTION 'DD_DOMA_GET'
EXPORTING
domain_name = 'ZECAT' " Domain name of ZPRS_Offshore
langu = sy-langu
withtext = 'X'
TABLES
dd07v_tab_a = it_taba
dd07v_tab_n = it_tabb
EXCEPTIONS
illegal_value = 1
op_failure = 2
OTHERS = 3.
" Pass the value for the field, you will get the domain value description in it_taba-DOMVALUE_L
READ TABLE it_taba WITH KEY VALPOS = wa_itab-zprs_offshore.
‎2013 Nov 28 6:36 AM
hi,
my code is
R :it_taba, it_tabb.
CALL FUNCTION 'DD_DOMA_GET'
EXPORTING
domain_name = 'Z_PRS_Offshore' " Domain name of ZPRS_Offshore
langu = sy-langu
withtext = 'X'
TABLES
dd07v_tab_a = it_taba
dd07v_tab_n = it_tabb
EXCEPTIONS
illegal_value = 1
op_failure = 2
OTHERS = 3.
READ TABLE it_taba into wa_taba WITH KEY VALPOS = wa_tab-zprs_offshore
but finally I have to display under loop it_tab into wa_tab in smartforms table?
‎2013 Nov 28 6:49 AM
You have two options, either add a zprs_offshore description field (Character field withe required length) in ty_tab. And modify the table to update the table it_itab.
types: begin of ty_tab.
...
...
..
offsh_desc type char10 ,
...
end of ty_tab.
lv_ofsdesc type char10.
loop at it_itab into wa_itab.
" Use the above code to get the description in lv_ofsdesc = it_taba-domvalue_l.
perform get_domain.
wa_itab-offsh_desc = lv_ofsdesc.
modify it_itab from wa_itab index sy-tabix transport offsh_desc.
endloop.
Now you can use the field wa_itab-offsh_desc in your smartform.
Another option would be to call the above FM within the loop in the smartform. And providing the variable having the output in the smartform.
Btw, if there are only two values for zprs_offshore, you could just manually fill the offsh_desc field without calling the FM.
if wa_itab-zprs_offshore = '1'.
wa_itab-offsh_desc = 'ON'.
else.
wa_itab-offsh_desc = 'OFF'.
endif.
modify table it_itab from wa_itab index sy-tabix transporting offsh_desc.
‎2013 Nov 28 7:26 AM
‎2013 Nov 28 5:18 AM
Please check your internal table on which you are making this Collect. After collect you can delete IT_ITAB where ZPRS_ROLE = ''.
Nabheet
‎2013 Nov 28 5:33 AM
Collect statement will sum up all the numeric values only when all the character values are equal. In your case value of 'ZPRS_OFFSHORE' value differs for both lines hence you are getting a new line.
-Venkat
‎2013 Nov 28 5:42 AM
hi venkat,
yes here zprs_offshore value is diff.......then how can I add the fkimg and netwr and display only addition value in smartforms?
‎2013 Nov 28 6:07 AM
Hi-
If you have got nothing to do with that value before collect statement clear that particular field value and please use separate table for collect statement.
-Venkat
‎2013 Nov 28 5:38 AM
Why dont you take vbeln posnr as your key fields in internal table.
Regards
Vivek
‎2013 Nov 28 5:43 AM
hi vivek ,
I alrady take vbeln as key field in internal table..
‎2013 Nov 28 5:45 AM
Hi
Try like this
Types : begin of ty_final,
a type string,
b type p LENGTH 7 DECIMALS 3,
end of ty_final.
data : it_final type TABLE OF ty_final,
it_final1 type TABLE OF ty_final,
wa_final type ty_final.
wa_final-a = 'SAP CONSULTANT'.
wa_final-B = '8.000'.
APPEND WA_FINAL TO IT_FINAL.
CLEAR WA_FINAL.
wa_final-a = 'SAP CONSULTANT'.
wa_final-B = '8.000'.
APPEND WA_FINAL TO IT_FINAL.
CLEAR WA_FINAL.
Loop at it_final into wa_final.
collect wa_final into it_final1.
endloop.
Loop at it_final1 into wa_final.
Write :/ wa_final-a, wa_final-b.
endloop.