Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

plz solve my problem

Former Member
0 Likes
2,048

hi frnds

we need to develop a report on PO release time lines.

Internal table: t_cdpos(OBJECTID FNAME CHANGENR VALUE_NEW VALUE_OLD).

After select stmt, get these values.


RowOBJECTIDFNAMECHANGENRVALUE_NEWVALUE_OLD
11000003FRGZU637324XXX
21000003FRGZU637323X
31000003FRGZU637322 XX
41000003FRGZU637302XXX
51000003FRGZU637301X
61000003FRGZU637300 XX
71000003FRGZU637299XXX
81000003FRGZU637298XXX
91000003FRGZU637224XX
101000004FRGZU637223X
111000004FRGZU637225 X
121000004FRGZU637226X
131000004FRGZU637227XXX
141000007FRGZU637236X
151000007FRGZU637237XXX
161000007FRGZU637238XXXXX
171000007FRGZU637239XXXXX
181000007FRGZU637240XXXXX
191000007FRGZU637241XXXXXXX

The no. of ‘X’ denotes the release against the levels of approvers found earlier. From this, the highest change doc num against each value of ‘X’, ‘XX’, ‘XXX’

i want to only for this below values.

RowOBJECTIDFNAMECHANGENRVALUE_NEWVALUE_OLD
11000003FRGZU637324XXX
21000003FRGZU637323X
121000004FRGZU637226X
131000004FRGZU637227XXX
141000007FRGZU637236X
151000007FRGZU637237XXX
181000007FRGZU637240XXXXX
191000007FRGZU637241XXXXXXX

frnds how i can get the our requirement. any one plz help me that.

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,851

Did you try to delete from internal table records where new value is lower or equal than old value ?

Regards,

Raymond

Hi Kumar,

Please try the below code for your requirement.

" loop for your internal table

loop at t_cdpos into wa_cdpos.

length_new = strlen( wa_cdpos-value_new ).

length_old = strlen( wa_cdpos-value_old ).

if length_new le lenght_old.

delete t_cdpos index sy-tabix.

endif.

endloop.

Thanks

Vivek

12 REPLIES 12
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,852

Did you try to delete from internal table records where new value is lower or equal than old value ?

Regards,

Raymond

Read only

0 Likes
1,851

Just to be sure, does this give the correct output?

For eg for objID 1000007, this logic would give both 637238 and 637240 as for both, new value is greater than old value. But the requirement is to get only the higher change number 637240 right?

Read only

0 Likes
1,851

I agree with , my answer was only a hint to remove "rollback" records, a SORT BY OBJECTID VALUE_NEW CHANGENR DESCENDING followed by a DELETE ADJACENT DUPLICATES is required to remove duplicates keeping only last value change.

Regards,

Raymond

Read only

0 Likes
1,851

This message was moderated.

Read only

0 Likes
1,851

yes,

example:

objID = 1000007

if new_value = 'X" and old_value  = ' '.

suppose get multiple values, will be taken higher change value and delete  low change value in table.

elseif new_value = 'XX" and old_value  = 'X'.

get multiple values, will be taken highest change value and delete low change value in table.

elseif new value = 'XXX' and old_value = "XX'.

get multiple values, will be taken highest change value and delete low change value in table.

.

.

.

Same procedure as follow for all object ids.

objectid = 1000003.

same as above procedure.

Read only

0 Likes
1,851

Did you try the code I had posted?

Your problem is solved ?

Read only

Former Member
0 Likes
1,851

Hi Kumar,

Please check the output set that you require, all you need to do is loop at the internal table and check if the VALUE_NEW GT VALUE_OLD. If this condition satisfy, append this record in final internal table.

Revert if you need more details.

Regards,

DN.

Read only

Former Member
0 Likes
1,851

Hi Kumar,

Please try the below code for your requirement.

" loop for your internal table

loop at t_cdpos into wa_cdpos.

length_new = strlen( wa_cdpos-value_new ).

length_old = strlen( wa_cdpos-value_old ).

if length_new le lenght_old.

delete t_cdpos index sy-tabix.

endif.

endloop.

Thanks

Vivek

Read only

Former Member
0 Likes
1,851

free the tables before you process

Read only

Former Member
0 Likes
1,851

The requirement you specified is not clear can you tell if you are displaying record no 2 then why 5 and 10 is not considered . I hope you can count the length and do like this.

Delete itab where deduct is LE 0.

regards,

Rahul

Read only

Former Member
0 Likes
1,851

This code will do your work.

Declare another internal table with same structure of  t_cdpos,

let it be t_cdpos_fin.


data : wa_cdpos   like line of t_cdpos,

         wa_cdpos1 like line of t_cdpos

* Current Results

loop at t_cdpos into wa_cdpos.
   write : /
wa_cdpos.
  endloop.

sort
t_cdpos by objectid ASCENDING value DESCENDING changenr descending.

loop at
t_cdpos into wa_cdpos.

     if
wa_cdpos1-value NE wa_cdpos-value and wa_cdpos-value NE ' '.
       APPEND
wa_cdpos to t_cdpos_fin.
     endif.
      
wa_cdpos1 = wa_cdpos.

ENDLOOP.

* Here by value I mean value_new, as i understand, only that is considered.

* Required Results

  skip 3.
  loop at
t_cdpos_fin into wa_cdpos1.
   write : /
wa_cdpos1.
endloop.

Cheers,

Susmitha

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,851

Moderator message: Please use proper subject line in future. This is a kind of "do my job" post, please be sure that you mention your effort in your next question.

I recommend to read the useful Blog "Asking Good Questions in the SCN Discussion Spaces will helpyou get Good Answers" to learn the principles of asking questions.