cancel
Showing results for 
Search instead for 
Did you mean: 

about comma display

Former Member
0 Kudos

Hi,

I have a question about sap scripts.

There're three fields in the form,devided with comma.

for example:

Location:&street&,&city&,&state&

but not every fields always have data, when &street& and &city& are empty,&state& = 'USA',result will be like this:

Location:,,USA

I want to hide the first two commas,how to deal with it.

a solution is:

If &street& = ' '

Location:&city&,&state&

endif

.

.

.

but if like that ,I must write many 'if' to shown different situation.A little prolixity.

Do you have some simple methods?

Message was edited by:

yang zou

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Try to embed the comma with the field name.

E.g: &street','& &city','& &state& ...

The comma will be displayed only if the field it is attached to contains a value at run-time.

Former Member
0 Kudos

Thanks to all the friends,the best and easiest method is from Manoj Kumar :

Solution should be:

&street& &','city& &','state&

and Vivek Kute's solution is also helpful.

I'll reward points immediately,

Thanks very much!

Message was edited by:

yang zou

Answers (4)

Answers (4)

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Just try this whether it is working.If so,kindly reward points.

data v1(40).

v1 = &street&.

if not &street& is initial.

concatenate v1 ',' into v1.

endif.

concatenate v1 &city& into v1.

if not &city& is initial.

concatenate v1 ',' into v1.

endif.

concatenate v1 &state& into v1.

Message was edited by:

Jayanthi Jayaraman

Former Member
0 Kudos

concatenate &street& &city& &state& into location separted by ','.

shift left LOCATION deleting leading ','.

former_member193831
Active Participant
0 Kudos

hi Yang,

I had encounter similar situation.

Here is what I did.

Tag SAPScript text

  • Location:,,

/: if &street& NE ' '

= &street&,

/: endif

/: if &city& NE ' '

= &city&,

/: endif

/: if &state& NE ' '

= &state&

/: endif

= tag means the texts will be on same line as ofg 'Location' text.

and If endif will ensure they are displayed only if NOT BLANK.

Regards,

Vivek Kute.

Reward points if helps.

Sandeep_Kumar
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi yang,

a solution is:

If &street& = ' '

Location:&city&,&state&

endif

U have to use the if and elseif nested condition.

Hope this helps.

Former Member
0 Kudos

Hi Yang,

As you have given

If &street& = ' '

Location:&city&,&state&

endif.

.

..

Only this is possible .

There is no other option to avoid comma.

Regards,

Guru

.