cancel
Showing results for 
Search instead for 
Did you mean: 

SAPScript

Former Member
0 Kudos

I want to declare a variable in sapscript. I want it's value to be calculated from the program. Here is what I am doing.

Code in SAPScript:

DEFINE &LV_LEN& = ' '

PERFORM SUB_ALIGN IN PROGRAM ZCSVM_DEL_NOTE_JP

USING &W_HEADER-SHIP_TO_NAME4&

CHANGING &LV_LEN&

ENDPERFORM

IF &LV_LEN& = '3'

...........

...........

ENDIF

Code in Program ZCSVM_DEL_NOTE_JP:

FORM SUB_ALIGN TABLES in_tab STRUCTURE itcsy

out_tab STRUCTURE itcsy.

DATA: LV_SHIP_TO_NAME4 TYPE c,

LV_LEN TYPE i.

READ TABLE in_tab INDEX 1.

WRITE in_tab-value TO LV_SHIP_TO_NAME4.

READ TABLE out_tab INDEX 1.

DESCRIBE FIELD LV_SHIP_TO_NAME4 LENGTH LV_LEN IN CHARACTER MODE.

out_tab-value = LV_LEN.

MODIFY out_tab INDEX 1.

ENDFORM.

The value of the field &W_HEADER-SHIP_TO_NAME4& is 500. So I want that LV_LEN will return 3. But it is not working. Maybe there is some declaration problem.

Can anybody please help me to solve this out?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

The declared varaible for name4 in subroutine LV_SHIP_TO_NAME4 is having only one character. define it LV_SHIP_TO_NAME4(4) type c.

Regards,

Chandra Kavali

Answers (2)

Answers (2)

Former Member
0 Kudos

Thank you all for your suggestions.

Former Member
0 Kudos

So, what are you trying to obtain, actually,with this?

DESCRIBE FIELD LV_SHIP_TO_NAME4 LENGTH LV_LEN IN CHARACTER MODE.

That describes attributes of the data element, not the length of the data string. Is that you're trying to figure out? Do you want to know if the the number of digits in the length is 3?

if so:

data: data_length type i.
 
data_length = strlen( LV_SHIP_TO_NAME4 ).

 if data_length ge 100.
    lv_len = 3.
elseif data_length ge 10.
lv_lven = 2.
else.
lv_len = 1.
endif.

Is that what you're trying to do?