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

how to store the value to variable?

Former Member
0 Likes
889

hi

plz c the below code...

my prblm is i want to store the value of wa_final-preis into new_xeipa-preis if there is only one ebeln...

if there are more procss orders then i want to save the first value to new_xeipa-preis wn second record comes then new_xeipa-preis should be replaced by new value and old_xeipa-preis replaced by old value....

how to do this?

LOOP AT xeipa INTO wa_xeipa.
  idx = sy-tabix.
  CLEAR: wa_xeina.

    READ TABLE xeina INTO wa_xeina WITH KEY infnr = wa_xeipa-infnr.
    IF sy-subrc is INITIAL.
    wa_final-infnr = wa_xeipa-infnr.
    wa_final-ebeln = wa_xeipa-ebeln.
    wa_final-bedat = wa_xeipa-bedat.
    wa_final-matnr = wa_xeina-matnr.
    wa_final-lifnr = wa_xeina-lifnr.
    wa_final-peinh = wa_xeipa-peinh.
    wa_final-preis = wa_xeipa-preis.        "net price
    wa_final-bprme = wa_xeipa-bprme.
    wa_final-bwaer = wa_xeipa-bwaer.

    IF ( wa_final-infnr is NOT INITIAL ) AND ( wa_final-ebeln is NOT INITIAL ) .
    ABWEICHUNG = ( new_xeipa-preis / old_xeipa-preis ) * 100 .
    ENDIF.
    append wa_final to it_final.
    ENDIF.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
786

Hi Smitha,

Check the below given code.

LOOP AT xeipa INTO wa_xeipa.
  idx = sy-tabix.
  CLEAR: wa_xeina.
 
    READ TABLE xeina INTO wa_xeina WITH KEY infnr = wa_xeipa-infnr.
    IF sy-subrc is INITIAL.
    wa_final-infnr = wa_xeipa-infnr.
    wa_final-ebeln = wa_xeipa-ebeln.
    wa_final-bedat = wa_xeipa-bedat.
    wa_final-matnr = wa_xeina-matnr.
    wa_final-lifnr = wa_xeina-lifnr.
    wa_final-peinh = wa_xeipa-peinh.
    wa_final-preis = wa_xeipa-preis.        "net price
    wa_final-bprme = wa_xeipa-bprme.
    wa_final-bwaer = wa_xeipa-bwaer.

" First time this value is not populated. When the second value comes in,
" New value gets populated in OLD variable and New value is replaced with the latest.
    *IF idx NE 1.*
      *old_xeipa-preis = new_xeipa-preis.*
    *ENDIF.*
 
    *new_xeipa-preis = wa_xeipa-preis.*

  IF ( wa_final-infnr is NOT INITIAL ) AND ( wa_final-ebeln is NOT INITIAL ) .
    ABWEICHUNG = ( new_xeipa-preis / old_xeipa-preis ) * 100 .
    ENDIF.
    append wa_final to it_final.
    ENDIF.
ENDLOOP.

I hope this is what you were looking for.

Thanks & Regards,

Ram.

Edited by: ram Kumar on Jun 12, 2009 5:16 PM

hi

plz c the below code...

my prblm is i want to store the value of wa_final-preis into new_xeipa-preis if there is only one ebeln...

if there are more procss orders then i want to save the first value to new_xeipa-preis wn second record comes then new_xeipa-preis should be replaced by new value and old_xeipa-preis replaced by old value....

how to do this?

LOOP AT xeipa INTO wa_xeipa.
  idx = sy-tabix.
  CLEAR: wa_xeina.

    READ TABLE xeina INTO wa_xeina WITH KEY infnr = wa_xeipa-infnr.
    IF sy-subrc is INITIAL.
    wa_final-infnr = wa_xeipa-infnr.
    wa_final-ebeln = wa_xeipa-ebeln.
    wa_final-bedat = wa_xeipa-bedat.
    wa_final-matnr = wa_xeina-matnr.
    wa_final-lifnr = wa_xeina-lifnr.
    wa_final-peinh = wa_xeipa-peinh.
    wa_final-preis = wa_xeipa-preis.        "net price
    wa_final-bprme = wa_xeipa-bprme.
    wa_final-bwaer = wa_xeipa-bwaer.

    IF ( wa_final-infnr is NOT INITIAL ) AND ( wa_final-ebeln is NOT INITIAL ) .
    ABWEICHUNG = ( new_xeipa-preis / old_xeipa-preis ) * 100 .
    ENDIF.
    append wa_final to it_final.
    ENDIF.

4 REPLIES 4
Read only

Former Member
0 Likes
787

Hi Smitha,

Check the below given code.

LOOP AT xeipa INTO wa_xeipa.
  idx = sy-tabix.
  CLEAR: wa_xeina.
 
    READ TABLE xeina INTO wa_xeina WITH KEY infnr = wa_xeipa-infnr.
    IF sy-subrc is INITIAL.
    wa_final-infnr = wa_xeipa-infnr.
    wa_final-ebeln = wa_xeipa-ebeln.
    wa_final-bedat = wa_xeipa-bedat.
    wa_final-matnr = wa_xeina-matnr.
    wa_final-lifnr = wa_xeina-lifnr.
    wa_final-peinh = wa_xeipa-peinh.
    wa_final-preis = wa_xeipa-preis.        "net price
    wa_final-bprme = wa_xeipa-bprme.
    wa_final-bwaer = wa_xeipa-bwaer.

" First time this value is not populated. When the second value comes in,
" New value gets populated in OLD variable and New value is replaced with the latest.
    *IF idx NE 1.*
      *old_xeipa-preis = new_xeipa-preis.*
    *ENDIF.*
 
    *new_xeipa-preis = wa_xeipa-preis.*

  IF ( wa_final-infnr is NOT INITIAL ) AND ( wa_final-ebeln is NOT INITIAL ) .
    ABWEICHUNG = ( new_xeipa-preis / old_xeipa-preis ) * 100 .
    ENDIF.
    append wa_final to it_final.
    ENDIF.
ENDLOOP.

I hope this is what you were looking for.

Thanks & Regards,

Ram.

Edited by: ram Kumar on Jun 12, 2009 5:16 PM

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
786

i think instead of read table u must loop .


data:cnt type sy-tabix.
cnt = 0.

LOOP AT xeipa INTO wa_xeipa.
  idx = sy-tabix.
  CLEAR: wa_xeina.
 clear cnt.
loop at xeina INTO wa_xeina where infnr = wa_xeipa-infnr.
add 1 to cnt.

if cnt = 1.
new_xeipa-preis = wa_xeipa-preis.
else.
old_xeipa-preis = new_xeipa-preis.
new_xeipa-preis = wa_xeipa-preis.
endif.

    wa_final-infnr = wa_xeipa-infnr.
    wa_final-ebeln = wa_xeipa-ebeln.
    wa_final-bedat = wa_xeipa-bedat.
    wa_final-matnr = wa_xeina-matnr.
    wa_final-lifnr = wa_xeina-lifnr.
    wa_final-peinh = wa_xeipa-peinh.
    wa_final-preis = wa_xeipa-preis.        "net price
    wa_final-bprme = wa_xeipa-bprme.
    wa_final-bwaer = wa_xeipa-bwaer.
 
    IF ( wa_final-infnr is NOT INITIAL ) AND ( wa_final-ebeln is NOT INITIAL ) .
    ABWEICHUNG = ( new_xeipa-preis / old_xeipa-preis ) * 100 .
    ENDIF.
    append wa_final to it_final.
    ENDIF.

endloop.

Read only

Former Member
0 Likes
786

Hi,

Please try using at end of .. or at new additions...

Here, is a sample code...



 LOOP AT xeipa INTO wa_xeipa.
    lv_count = lv_count + 1.
    AT END OF ebeln.
       gs_total-cov_total  = lv_count.
      APPEND gs_total TO gt_total.
      CLEAR : gs_total,
              lv_count,
              gs_details.
    ENDAT.
  ENDLOOP.

Hope it gives you some idea.. Let me know if your problem still persits.

Read only

matt
Active Contributor
0 Likes
786

>

> hi

>

> plz c the below code...

> my prblm is...

"Please see the below code...

My problem is..."

Please resist the temptation to use shortened "text-message/SMS" type words. It is against the forum rules. Not all contributers are fluent in English and so cannot understand shortened words. Please be respectful to them.

matt