Application Development 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: 

problem in charecters.

Former Member
0 Kudos

Hi experts,

i have a small problem. like am using the field mseg-sgtxt.

i need to add some fields to get total.but in these fields there are some charecters like AB, BC like that so i cannot total it. so when there are charecters i want to push them in a variable.else if they have values i want to total them.

so am using like this

if wa_mseg-sgtxt ca sy-abcde

variable = wa_mseg-sgtxt.

else.

total= wa_mseg-sgtxt + wa_mseg-sgtxt1.

endif.

but am not getting with this..

help me if u have more suggestions

Regards

Sunita

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Experts,

the field sgxtx has numbers and charecter..so am separting them. and summing up the numbers. but some are only charecters..so i want to push them to a variable so how to solve it..

IF WA_MSEG-RIPE  CA SY-ABCDE OR
       WA_MSEG-UDRIPE CA SY-ABCDE OR
       WA_MSEG-UNRIPE CA SY-ABCDE OR
       WA_MSEG-OVRRPE CA SY-ABCDE OR
       WA_MSEG-EMPTY CA SY-ABCDE OR
       WA_MSEG-ROTTEN CA SY-ABCDE.

      CONCATENATE WA_MSEG-RIPE
                  WA_MSEG-UDRIPE
                  WA_MSEG-UNRIPE
                  WA_MSEG-OVRRPE
                  WA_MSEG-EMPTY
                  WA_MSEG-ROTTEN
                  INTO
                  L_TEXT.

    ELSE.

      TOTAL = WA_MSEG-RIPE + WA_MSEG-UDRIPE + WA_MSEG-UNRIPE + WA_MSEG-OVRRPE + WA_MSEG-EMPTY + WA_MSEG-ROTTEN.

    ENDIF.

i have pasted the code..so i need ur valauble inputs

Regards

Sunita.

7 REPLIES 7

madan_ullasa
Contributor
0 Kudos

if wa_mseg-sgtxt ca sy-abcde

variable = wa_mseg-sgtxt.

else.

************************

assign this to a type p variable...

e.g.

wa_num = wa_mseg-sgtxt.

*****************

total= wa_mseg-sgtxt + wa_mseg-sgtxt1.

endif.

try this... if not type p try type n...

regards,

Madan....

former_member181995
Active Contributor
0 Kudos
if wa_mseg-sgtxt ca sy-abcde
  variable = wa_mseg-sgtxt.
 else.
 total= wa_mseg-sgtxt + wa_mseg-sgtxt1."This is wrong cause of type char of both wa_mseg-sgtxt and wa_mseg-sgtxt1
 endif.

You cannot total wa_mseg-sgtxt at all cause it is char type and there is no possibility of total of type char even if their values contain numeric.

so you can do one thing you may collect both wa_mseg-sgtxt and wa_mseg-sgtxt1 values in some varibale which must be type P or numeric and do total variable + variable1.

Edited by: Ámit Güjärgoüd on Oct 8, 2008 6:18 AM

Former Member
0 Kudos

Hi

Try to move wa_mseg-sgtxt to numeric field and than add.

What if wa_mseg-sgtxt is having value something like ' 1 1 1'.

I mean there is space between each numbers.

The totalling may not work properly.

Hence take a wa_mseg-sgtxt to separate character field, condense that varaiable and than try to move to numeric field and than add

Regards

Madhan

Former Member
0 Kudos

Hi Experts,

the field sgxtx has numbers and charecter..so am separting them. and summing up the numbers. but some are only charecters..so i want to push them to a variable so how to solve it..

IF WA_MSEG-RIPE  CA SY-ABCDE OR
       WA_MSEG-UDRIPE CA SY-ABCDE OR
       WA_MSEG-UNRIPE CA SY-ABCDE OR
       WA_MSEG-OVRRPE CA SY-ABCDE OR
       WA_MSEG-EMPTY CA SY-ABCDE OR
       WA_MSEG-ROTTEN CA SY-ABCDE.

      CONCATENATE WA_MSEG-RIPE
                  WA_MSEG-UDRIPE
                  WA_MSEG-UNRIPE
                  WA_MSEG-OVRRPE
                  WA_MSEG-EMPTY
                  WA_MSEG-ROTTEN
                  INTO
                  L_TEXT.

    ELSE.

      TOTAL = WA_MSEG-RIPE + WA_MSEG-UDRIPE + WA_MSEG-UNRIPE + WA_MSEG-OVRRPE + WA_MSEG-EMPTY + WA_MSEG-ROTTEN.

    ENDIF.

i have pasted the code..so i need ur valauble inputs

Regards

Sunita.

0 Kudos

Your logic is watching at all characters if any single character is contain alphabets than your IF condition would be satisfied.

you may need to check char by char.and moreover you are using OR between IF condition which is also ahould be AND i think.

0 Kudos

Decalare separate variables

DATA : TEMP_RIPE TYPE N

TEMP_UDRIPE TYPE N,

TEMP_UNRIPE TYPE N,

TEMP_OVRRPE TYPE N,

TEMP_EMPTY TYPE N,

TEMP_ROTTEN TYPE N.

In the else Part.

condense wa_mseg-ripe.

temp_ripe = wa_mseg-ripe.

do the above for all fields.

and add

total = temp_ripe + temp_udripe .... all the fields.

Regards

Madhan

0 Kudos

Hi amit,

how to check char by char ,can u tell me exactly..

Regards

Sunita