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

Set variable type P empty

Former Member
0 Likes
1,564

Hello,

how is it possible to set a variable of type P empty in SAP?

I have tried allready:

variable = ''.

But the output for my variable will be 0, I just need it to show nothing!

Thanks

Anne

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,517

Your question seems pretty basic. Are you asking about how to write it so that no-zero appear??

Rob

14 REPLIES 14
Read only

Former Member
0 Likes
1,519

Your question seems pretty basic. Are you asking about how to write it so that no-zero appear??

Rob

Read only

0 Likes
1,517

Yes, correct, I just want nothing to appear, no zeros, just blank. How can I do that?

Thanks

Anne

Read only

0 Likes
1,517

Just read my first response. The answer lies within.

Rob

Read only

0 Likes
1,517

Hi Rob,

so this is your first response:

"Your question seems pretty basic. Are you asking about how to write it so that no-zero appear??"

I don't really see what I can do, so can you please help me out here?

Thanks

Anne

Read only

0 Likes
1,517

Press F1 on WRITE and then look at the formatting options.

Rob

Read only

0 Likes
1,517

Ok, got it, I guess I am a little slow today..

Thanks!!

Read only

0 Likes
1,517

F1 will solve a very high percentage of the questions asked here; searching the forums or using Google will get most of the rest.

Glad to help

Rob

Read only

0 Likes
1,517

Hi Rob,

I am sorry, but it doesn't seem to work for me, I used

write MIXEDPACKS-PACKS1 NO-ZERO.

I debugged it but it is still showing zero in debugging as well as in the output.

Thanks

Anne

Read only

0 Likes
1,517

How is MIXEDPACKS-PACKS1 declared?

Rob

Read only

0 Likes
1,517

*data declaration for #packs

DATA: BEGIN OF MIXEDPACKS,

PACKS1 TYPE P DECIMALS 0,

PACKS2 TYPE P DECIMALS 0,

DATA: END OF MIXEDPACKS.

Read only

0 Likes
1,517
DATA: BEGIN OF mixedpacks,
        packs1 TYPE p DECIMALS 0,
        packs2 TYPE p DECIMALS 0.
DATA: END OF mixedpacks.

mixedpacks-packs2 = 5.

WRITE: /001 mixedpacks-packs1    NO-ZERO,
            mixedpacks-packs2    NO-ZERO,
            mixedpacks-packs1    NO-ZERO,
            mixedpacks-packs2    NO-ZERO,
            mixedpacks-packs1    NO-ZERO,
            mixedpacks-packs2    NO-ZERO.

gives:

> 5 5 5

which is I think what you want.

The formatting is not very good, but the 0's show as spaces.

Rob

Edited by: Rob Burbank on Jan 15, 2010 3:51 PM

Read only

0 Likes
1,517

Yes, basically that is what I want. But the "NO-ZERO" command doesn't save the value with no zeros back into the variable mixedpacks-packs1, correct? It just gives me the output with no zeros?

Problem is that I need to print the variable on a barcode label with sapscript and I cannot use the "write x no-zero" command there.

I already tried to enter &mixedpacks-packs1(Z)& into my sapscript form where I figured the '(Z)' would eleminate all leading zeros, but it doesn't in this case, maybe because there is only one zero there.

Read only

0 Likes
1,517

>

> Problem is that I need to print the variable on a barcode label with sapscript and I cannot use the "write x no-zero" command there.

That's the sort of thing it would be nice to know at the beginning.

You can try conditionally move values to character fields.

Rob

Edited by: Rob Burbank on Jan 15, 2010 4:24 PM

Read only

0 Likes
1,517

Hi Rob,

I tried to move it to a character field and the zeros don't show anymore, but now if there is a value in the P field, it shows up as * in the character field.

I am now trying to use FM PACK_CHAR_CONVERSION to convert the value from P to C, but I don't get it to work.

Thanks for your help

Anne