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: 

How to replace blank value with space in abap

uirji_netweaver
Participant
0 Kudos
1,865

Hi Team,

i need to populate space if filed value is blank.

im reading data from itab to file, few fields of itab contain blank value ,

CONCATENATE: <gfs_data>-znachn
<gfs_data>-zmidnm
<gfs_dara>-zvorna
<gfs_data>-zbnksa

gfs_data>-zstat

<gfs_data>-zstrt1
<gfs_data>-zstrt2
<gfs_data>-zcity
<gfs_data>-zstate

<gfs_data>-zworloc INTO gs_output SEPARATED BY gc_sep1.

so my output file created in application server as below.

devediano~~Ckrole~70002348~~Outvendor RN CAP 1~~3107580~~~~11170000~0010.

now how do i insert space between ~~ ?

so my output file should be as beow.

devediano~ ~Ckrole~70002348~ ~Outvendor RN CAP 1~~3107580~ ~ ~ ~11170000~0010.

Thank you

NK

1 ACCEPTED SOLUTION

uirji_netweaver
Participant
0 Kudos
833

Hi sathish,

Thanks for the reply, i added logic that " if no value populate "#" to itab, but when again replace it with space ..the output is again same as old.

devediano~#~Ckrole~70002348~#~Outvendor RN CAP 1~#~3107580~#~#~#~11170000~0010.

REPLACE ALL OCCURRENCES OF '#' IN gs_output WITH '~'.

devediano~ ~Ckrole~70002348~ ~Outvendor RN CAP 1~~3107580~ ~ ~ ~11170000~0010.

Please suggest.

thanks

6 REPLIES 6

former_member1716
Active Contributor
0 Kudos
833

uirji.netweaver,

Understand your issue, your problem here is you will not be able to know if there is value missing in a line item. But both blank and space values looks same in system.

What I would suggest is, before concatenation check if the fields hold some value. If they don't hold any value replace them with a special character probably # or $. This should help you identify in case there is a empty value.

Recommend you to go through the Thread as well.

Regards

matt
Active Contributor
0 Kudos
833

REPLACE ALL OCCURRENCES OF '~~' IN string WITH '~ ~'.

matt
Active Contributor
833

You're not replace a blank character. The character doesn't exist. You're inserting a character between two others.

Answer is below.

uirji_netweaver
Participant
0 Kudos
834

Hi sathish,

Thanks for the reply, i added logic that " if no value populate "#" to itab, but when again replace it with space ..the output is again same as old.

devediano~#~Ckrole~70002348~#~Outvendor RN CAP 1~#~3107580~#~#~#~11170000~0010.

REPLACE ALL OCCURRENCES OF '#' IN gs_output WITH '~'.

devediano~ ~Ckrole~70002348~ ~Outvendor RN CAP 1~~3107580~ ~ ~ ~11170000~0010.

Please suggest.

thanks

uirji_netweaver
Participant
0 Kudos
833

Hi Matthew,

i tried with REPLACE ALL OCCURRENCES OF '~~' IN string WITH '~ ~'. , this is working if 2 fileds are missing but not working for 3 serial fields .

Example

devediano~~Ckrole~70002348~~Outvendor RN CAP 1~~3107580~~~11170000~0010.

REPLACE ALL OCCURRENCES OF '~~' IN string WITH '~ ~'.

devediano~ ~Ckrole~70002348~ ~Outvendor RN CAP 1~ ~3107580~ ~~11170000~0010.

Thank you

uirji_netweaver
Participant
0 Kudos
833

Thanks all

its working when i use TRANSLATE gs_output USING '#

thanks

'.