2009 Apr 20 7:12 AM
hi all,
i need to fetch the data based on BELNR BUKRS and ZUONR
The data is
BELNR BUKRS ZUONR DMBTR
1001 0005 TP004 5
1001 0005 TP006 4
1001 0005 PK458 10
1001 0005 PK876 2
1001 0005 PK999 50
The output should be as
BELNR BUKRS ZUONR DMBTR
1001 0005 TP006 9
1001 0005 PK999 62
If ZUONR field first 2 alphabets are same those DMBTR values should be added and ZUONR output should be last value of the first 2 alphabets
suppose for above eg:
ZUONR = TP004 = 5
TP006 = 4
-
9
-
ZUONR Should display the highest of first 2 alphabtes i.e., coming to TP, the highest is TP006
THE output should be as
BELNR BUKRS ZUONR DMBTR
1001 0005 TP006 9
please see code below
i have added the all DMBTR values ,if FIRST 2 alphabets of ZUONR ARE SAME but how to pass zuonr highest value to output.
now the output is coming as
BELNR BUKRS ZUONR DMBTR
1001 0005 TP-----(missing 006) 9
only 2 fields of ZUONR is displaying, while adding DMBTR it should compare with first 2 alphabets of ZUONR But while displaying in the output the Zuonr should be highest value of the first 2 alphabets,
LOOP AT gt_bseg.
gt_output-belnr = gt_bseg-belnr.
gt_output-zuonr+0(2) = gt_bseg-zuonr.
gt_output-dmbtr = gt_bseg-dmbtr.
gt_output-wrbtr = gt_bseg-wrbtr.
COLLECT gt_output.
CLEAR gt_output.
ENDLOOP.
please help
hi all,
i need to fetch the data based on BELNR BUKRS and ZUONR
The data is
BELNR BUKRS ZUONR DMBTR
1001 0005 TP004 5
1001 0005 TP006 4
1001 0005 PK458 10
1001 0005 PK876 2
1001 0005 PK999 50
The output should be as
BELNR BUKRS ZUONR DMBTR
1001 0005 TP006 9
1001 0005 PK999 62
If ZUONR field first 2 alphabets are same those DMBTR values should be added and ZUONR output should be last value of the first 2 alphabets
suppose for above eg:
ZUONR = TP004 = 5
TP006 = 4
-
9
-
ZUONR Should display the highest of first 2 alphabtes i.e., coming to TP, the highest is TP006
THE output should be as
BELNR BUKRS ZUONR DMBTR
1001 0005 TP006 9
please see code below
i have added the all DMBTR values ,if FIRST 2 alphabets of ZUONR ARE SAME but how to pass zuonr highest value to output.
now the output is coming as
BELNR BUKRS ZUONR DMBTR
1001 0005 TP-----(missing 006) 9
only 2 fields of ZUONR is displaying, while adding DMBTR it should compare with first 2 alphabets of ZUONR But while displaying in the output the Zuonr should be highest value of the first 2 alphabets,
LOOP AT gt_bseg.
gt_output-belnr = gt_bseg-belnr.
gt_output-zuonr+0(2) = gt_bseg-zuonr.
gt_output-dmbtr = gt_bseg-dmbtr.
gt_output-wrbtr = gt_bseg-wrbtr.
COLLECT gt_output.
CLEAR gt_output.
ENDLOOP.
please help
2009 Apr 20 7:15 AM
Hello,
Try the following :
After the Collect stmt inside the loop,
MODIFY GT_OUTPUT.
Hope this helps,
Regards,
Mansi.
2009 Apr 20 7:23 AM
Hi,
First of all sort the internal table by field zuonr, than you can make use of the logic for addition of dmbtr.
To get the highest Zuonr you can use logic as below:
if gt_bseg-zuonr+0(2) eq lv_zuonr.
gt_output-zuonr = gt_bseg-zuonr.
else.
lv_zuonr = gt_bseg-zuonr+0(2).
gt_output-zuonr = gt_bseg-zuonr.
endif.
Hope this helps.
2009 Apr 20 7:33 AM
HI KRITESH,
this is my code where do i need to put your code.
LOOP AT gt_bseg.
gt_output-belnr = gt_bseg-belnr.
gt_output-zuonr+0(2) = gt_bseg-zuonr.
gt_output-dmbtr = gt_bseg-dmbtr.
gt_output-wrbtr = gt_bseg-wrbtr.
COLLECT gt_output.
CLEAR gt_output.
ENDLOOP.
2009 Apr 20 7:44 AM
Hi,
1. sort gt_bseg in descending value of zuonr.( so you will get the hightest values).
2. create another internal table and move the fields belnr, zuonr, wrbtr into it.
3. then pass the total value in dmbtr into the internal table.
4. modify it.
thanks.
2009 Apr 20 8:15 AM
Can i use control break statement to get the last value of the ZUONR which has FIRST 2 alphbets same.
if so please help with code.
thanks in advance
2009 Apr 20 10:53 AM
Hi,
You can try this logic.
1. decalre a local variable lv_zuonr, lv_dmbtr and lv_count.
loop at gt_bseg into gs_bseg.
lv_zuonr = gs_bseg-zuonr0(2).
if lv_zuonr = gs_bseg-zuonr0(2).
if lv_count = 1.
lv_dmbtr = gs_bseg-dmbtr.
lv_zuonr1 = gs_bseg-zounr.
else.
if lv_dmbtr > gs_besg-dmbtr.
gs_bseg-zounr = lv_zuonr1.
gs_bseg-dmbtr = lv_dmbtr + gs_bseg-dmbtr.
modify gt_bseg from gs_bseg transporting zuonr dmbtr.
endif.
endif.
endif.
endloop.
2009 Apr 20 11:13 AM
Hey..
Check this....
Have another internal table say T_ITAB2 with same structure as of the internal table in which these fields are there...Let the original table be T_ITAB1.
DATA: l_index type sy-tabix.
l_zuonr type... declare this.
LOOP at T_ITAB1 into WA_ITAB1.
l_index = sy-tabix.
do.
add 1 to l_index.
read table T_ITAB2 into WA_ITAB2 index l_index.
if sy-subrc = 0.
l_zuonr = l_zuonr + wa_itab2-zuonr.
else.
wa_itab2-zuonr = l_zuonr.
append wa_itab2 to t_itab2.
exit.
endif.
enddo.
ENDLOOP.
Once this code is executed... T_ITAB2 will have the entries as you need ....
If you are not gettin the correct output.. then sort the tables appropriately..
Cheers..
2009 Apr 23 7:06 AM
try this ---
TYPES: BEGIN OF it1,
BELNR(4),
BUKRS(4),
ZUONR(5),
DMBTR TYPE i,
END OF it1.
DATA: it_1 TYPE TABLE OF it1 WITH HEADER LINE,
it_2 TYPE TABLE OF it1 WITH HEADER LINE.
data: v1(4), v2(4), v3(5), v4 TYPE i.
PERFORM in_data USING:
'1001' '0005' 'PK458' 10,
'1001' '0005' 'PK876' 2,
'1001' '0005' 'PK999' 50,
'1001' '0005' 'TP004' 5,
'1001' '0005' 'TP006' 4.
LOOP AT it_1.
IF v3 IS INITIAL.
v1 = it_1-BELNR.
v2 = it_1-BUKRS.
v3 = it_1-ZUONR.
v4 = it_1-DMBTR.
ELSEIF v30(2) ne it_1-ZUONR0(2).
it_2-BELNR = v1.
it_2-BUKRS = v2.
it_2-ZUONR = v3.
it_2-DMBTR = v4.
APPEND it_2.
v1 = it_1-BELNR.
v2 = it_1-BUKRS.
v3 = it_1-ZUONR.
v4 = it_1-DMBTR.
else.
v3 = it_1-ZUONR.
v4 = v4 + it_1-DMBTR.
ENDIF.
ENDLOOP.
it_2-BELNR = v1.
it_2-BUKRS = v2.
it_2-ZUONR = v3.
it_2-DMBTR = v4.
APPEND it_2.
LOOP AT it_2.
WRITE: / it_2-BELNR, it_2-BUKRS, it_2-ZUONR, it_2-DMBTR.
ENDLOOP.
FORM IN_DATA USING VALUE(a) VALUE(b) VALUE(c) VALUE(d) type i.
it_1-BELNR = a.
it_1-BUKRS = b.
it_1-ZUONR = c.
it_1-DMBTR = d.
APPEND it_1.
CLEAR it_1.
ENDFORM. " IN_DATA
hope this will help
Edited by: mayank jain on Apr 24, 2009 1:36 PM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |