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

concatenate space with internal table variable depending on condition

Former Member
0 Likes
1,485

Hi All,

I want to add space to the internal table variable depending on the condition. If the variable length is less than 30, it will add space after the variable and it will make the length as 30. i have given the sample code below,

data: len_g type char30 value ' '.

len1 = STRLEN( data-tplnr ).

IF len1 < con_30. *it will check length is less than 30

len2 = con_30 - len1.

concatenate data-tplnr+len_g(len2) into data-tplnr.

output-tplnr = data-tplnr.

APPEND output-tplnr TO intoutput-tplnr.

else.

*other part.

endif.

i am getting the error 'Unable to interpret data-tplnr+len_g(len2)' .

If the length of variable is 12, then the remaining length will be spaces after variable.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,293

data: len_g type char30 value ' '.

len1 = STRLEN( data-tplnr ).

IF len1 < con_30. *it will check length is less than 30

len2 = con_30 - len1.

concatenate data-tplnr len_g+0(len2) into data-tplnr.

output-tplnr = data-tplnr.

APPEND output-tplnr TO intoutput-tplnr.

else.

*other part.

endif.

Regards,

Lalit Mohan Gupta.

Hi All,

I want to add space to the internal table variable depending on the condition. If the variable length is less than 30, it will add space after the variable and it will make the length as 30. i have given the sample code below,

data: len_g type char30 value ' '.

len1 = STRLEN( data-tplnr ).

IF len1 < con_30. *it will check length is less than 30

len2 = con_30 - len1.

concatenate data-tplnr+len_g(len2) into data-tplnr.

output-tplnr = data-tplnr.

APPEND output-tplnr TO intoutput-tplnr.

else.

*other part.

endif.

i am getting the error 'Unable to interpret data-tplnr+len_g(len2)' .

If the length of variable is 12, then the remaining length will be spaces after variable.

7 REPLIES 7
Read only

Former Member
0 Likes
1,293

Hi Mukil,

try this..


IF len1  < con_30.
Split the variable into two characters as per your requrement.

and Format the two variables into two place's..


endif.

Regards,

Prabhudas

Read only

Former Member
0 Likes
1,293

If you wan to move to right if characters less than 30


IF len1 < con_30. *it will check length is less than 30
  write data-tplnr into data-tplnr right justified.
else.
*other part.
endif.

Read only

Former Member
0 Likes
1,293

HI,

You cannot increase the length of the field tplnr by adding extra space after the value. Even after adding spaces after the value and check the strlen it will return actual length excluding space.

Read only

Former Member
0 Likes
1,293

Hi,

U code like below:

data: len_g type char30 value ' '.

len1 = STRLEN( data-tplnr ).

IF len1 < con_30. *it will check length is less than 30

len2 = con_30 - len1.

do len2 times.

concatenate data-tplnr ` ` into data-tplnr.

enddo.

output-tplnr = data-tplnr.

APPEND output-tplnr TO intoutput-tplnr.

else.

*other part.

endif.

Hope it helps!!

Read only

Former Member
0 Likes
1,293

Hi vishnu,

if i print the barcode it is not giving me correct answer.

Read only

Former Member
0 Likes
1,294

data: len_g type char30 value ' '.

len1 = STRLEN( data-tplnr ).

IF len1 < con_30. *it will check length is less than 30

len2 = con_30 - len1.

concatenate data-tplnr len_g+0(len2) into data-tplnr.

output-tplnr = data-tplnr.

APPEND output-tplnr TO intoutput-tplnr.

else.

*other part.

endif.

Regards,

Lalit Mohan Gupta.

Read only

Former Member
0 Likes
1,293

Hi Mukilan,

You cannot print spaces in barcode after a variable. The last character should be a full stop or comma or something valid character. If there is a character in last place. you can print spaces in barcode between variable and last character. This is because after any varible, the system use to consider it as spaces. so, it wil not print any spaces after variable. Make sure that at last place there is a character.

Regards,

Sameer.