cancel
Showing results for 
Search instead for 
Did you mean: 

Pass blank spaces in a variable

Former Member
0 Kudos

hi All,

Is there anyway by which i can pass blank spaces to a variable.

Thanks & Regards,

Durgesh.

Moderator message: very basic -> question status removed.

Message was edited by: Thomas Zloch

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi All,

I have found the solution.

Just populate the final variable with the commas before as here we know that what is the field length.

and suppose if a variable is initial then we need not pass any value or spaces in place of that variable. Thus the spaces are incorporated in the final variable.


Thank you all for the suggestions and being patient with me.

Regards,

Durgesh.

Phillip_Morgan
Contributor
0 Kudos

Would need to know more about these requirements.

Your field of 4 spaces would be respected if it were in a structure. Example is when you create an output file. You can your structure fields the necessary sizes to respect the required column positions.

Another way to repsect spacing would be to delimit with characters:

X    X

Former Member
0 Kudos

Hi Philip,

My requirement is like i need to pass spaces in a variable and then that variable is concatenated with other variables. And the final variable is passed on to some third party system.
Other scenario is like just pass the space value to a variable directly. i have tried the above specified options but was not successful.

Regards,

Durgesh

Phillip_Morgan
Contributor
0 Kudos

Well Durgesh,

This third party must have given you a spec for the structure. Say:

Company char 15

Address char 30

City char 10

This is your structure:

data:

  begin of out_file,

    company(15) type c,

    address(30) type c,

    city(10) type c,

end of out_file.

So if you fill company and city but not address, you will have address empty. The data will be at all the right places for third party to find it.

This is the most common scenario used in all extractor programs usually.

Former Member
0 Kudos

But for me i need to say concatenate all three separated by comma and if address is empty than i need to pass 30 blank spaces for it. these all data is stored in a changing parameter of the user exit which i am using. The third party system needs that if address is initial it should have that much number of spaces.

Regards,

Durgesh.

Phillip_Morgan
Contributor
0 Kudos

Sound funny. Usually if you have a csv file (comma separated values) if the field is empty you have two commas touching, example:

Disney;;Burbank

your understanding is they want (I'm not counting the spaces):

Disney;                                            ;Burbank

usually you have either a csv file or a fixed position file (or whatever its called)

But, OK, then you structure should be:

data:

  begin of out_file,

    company(15) type c,

    sep1 type c value ',',

    address(30) type c,

    sep2 type c value ',',

    city(10) type c,

end of out_file.

This should give you:

Disney;                                            ;Burbank

If I understood...

Former Member
0 Kudos

Hi Philip,

There is no structure for me, I am passing all of the above fields to individual variables and concatenating all of them to pass in one variable. Now that variable should have the spaces.

Regards,

Durgesh

Phillip_Morgan
Contributor
0 Kudos

You complicate your life that way!

Use the structure approach!

You do something like this:

data:

    company(15) type c,

    address(30) type c,

    city(10) type c,

    big_field(200).

concatenate company address city into big_field separated by ','.

(but the empty field is shortened to nothing)

instead use a structure:

out_file-company = 'Disney'.

out_file-address  = space.

out_file-city = 'Burbank'.

big_field = out_file.

transfer big_field to file.

you will be transferring this:

Disney;                                        ;Burbank

I mean try it and see!

amy_king
Active Contributor
0 Kudos

Hi Durgesh,

I agree the structure approach may work for your requirement, however, you can always use a placeholder and the REPLACE keyword, e.g.,

DATA lv_char_string TYPE char20 VALUE 'Hello&World'.

REPLACE '&' WITH '    ' INTO lv_char_string.

This gives you

'Hello    World'

Cheers,

Amy

raymond_giuseppi
Active Contributor
0 Kudos

It depends on the variable type, is is a CHAR a STRING or another type, try a  MOVE ` ` TO STRING (backquotes), MOVE SPACE or CLEAR to a CHAR type.

Regards,

Raymond

Venkat_Sesha
Advisor
Advisor
0 Kudos

Just Pass keyword  GV_FLAG = SPACE.

What variable did you declared and what is the Type associated with it.

Former Member
0 Kudos

Hi Venkat,

My requirement is like if i have a char4 variable then i need to pass 4 blank spaces to that variable.

Thanks & Regards,

Durgesh.

Venkat_Sesha
Advisor
Advisor

When u pass SPACE to a CHAR4 Vaiable it will be only one SPACE thats it.

When u want to pass 4 Blank SPACEs also System will take it as one SPACE thats it.

Example LV_FLAG TYPE CHAR4.

1. LV_FLAG = SPACE.

2. LV_FLAG+0(1) = SPACE.

    LV_FLAG+1(2) = SPACE.

    LV_FLAG+2(3) = SPACE.

    LV_FLAG+3(4) = SPACE.

Now from point 1 and 2 system will take the as SPACE thats it. LV_FLAG will be a Blank Value.