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: 

Output not showing the spaces if field value is blank

Former Member
0 Kudos

Hi!

I am trying to concatenate two fields into one separated by a space and placing that value into a field in my output.SO the output looks something like this "SLGYD N' but the problem is that if either of the field is blank meaning theer is no value in it the output becomes distorted. Like if the filed 1 is blank and the field 2 is having a value 'N' the the output becomes 'N'. I want it to show the first 5 places which si the first field as 5 blank spaces instead of wiping out the space itself , so the output shown is like ' N' and not just 'N'.

lv_zeubcd = s_final-zzeubcd.
      if lv_mvgr1 = '001'.
         lv_mvgr1 = 'D'.
      else.
         lv_mvgr1 = 'N'.
      endif.
     if lv_zeubcd = ' '.
        
lv_zeubcd = '     '. <<<< not sure if this works or not
 concatenate lv_zeubcd lv_mvgr1 into lv_wascode separated by space.

Thanks

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Use Offset

Try this way

lv_wascode+0(5) = lv_zeubcd.

lv_wascode+5(1) = lv_mvgr1.

Regards

Krishna

6 REPLIES 6

former_member302911
Active Participant
0 Kudos

Hi,

Try RESPECTING BLANKS:

concatenate lv_zeubcd lv_mvgr1 into lv_wascode RESPECTING BLANKS.

Angelo.

0 Kudos

So addition of 'respecting blanks will leave my output with 5 blank spaces for the the field 1 if it is blank? The fild 1 consists on 5 character so it should leave me with 5 spaces and then write teh field2 which si 'N'..right? I mean I wanted an output like ' N' if the first field is empty or 'SLYGD ' if teh second field is empty.?

Thanks

Former Member
0 Kudos

Hi,

Try using cl_abap_char_utilities=>horizontal_tab.

i.e. concatenate var1 cl_abap_char_utilities=>horizontal_tab into final_variable.

Regards,

Nangunoori.

Former Member
0 Kudos

Hi,

Use Offset

Try this way

lv_wascode+0(5) = lv_zeubcd.

lv_wascode+5(1) = lv_mvgr1.

Regards

Krishna

0 Kudos

Thanks , I used offset as well as respecting blank and it works fine. I hope I could use this way?

lv_wascode+0(5) = s_final-zeubcd .

lv_wascode+5(1) = s_final-mvgr1.

concatenate lv_wascode0(5) lv_wascode5(1) into lv_wascode RESPECTING BLANKS.

Thanks

0 Kudos

But when I put the same code in my smartforms it gives me an error saying "Length specification "(5)" exceeds field length ("1")."

though it works absolutely fine in the program I used it. Since this smartform is connected to to the program I need to use the same logic to bring in the concatenation to my form too.

Thanks