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

Please provide code to populate space into a variable ?

Former Member
0 Likes
1,151

Hi Folks,

This is in regards to populate space into a variable as in BI reporting, we get # or NA (not assigned) values in the BI report if we don't have any values in the variable. I need to populate space into one of the variable when there is not value. Please find the below code and its not working, can anyone please fine tune it. More details of my problem are given in this link.

This code is not working. I need to populate space in 2 variable's. 1 variable is 2 length -Numeric format and other is 6 length - char format. Can anyone please help. Appreciate it.

If sy-subrc <> 0.
       RESULT = space.
     Else.
       RESULT = wa_itab-flag.
     Endif.


Thank You

DR

1 ACCEPTED SOLUTION
Read only

former_member228514
Participant
0 Likes
1,090

Hi Dr,

You can concatenate variable1 with length and separate it by space.

like this :-


concatenate Var1 len into RESULT SEPARATED BY space.

I hope this will resolve your problem.

Thanks,

Aarti

9 REPLIES 9
Read only

former_member228514
Participant
0 Likes
1,091

Hi Dr,

You can concatenate variable1 with length and separate it by space.

like this :-


concatenate Var1 len into RESULT SEPARATED BY space.

I hope this will resolve your problem.

Thanks,

Aarti

Read only

0 Likes
1,090

Thanks for the reply Aarti,

You mean like this... what will var1 to be declared ?  why will this statement "RESULT = space "not work ?

If sy-subrc <> 0.
   concatenate Var1 len into RESULT SEPARATED BY space.
     Else.
       RESULT = wa_itab-flag.
     Endif.

Read only

0 Likes
1,090

Hi,

Define a constant like below and assign it to your code.

TYPES:

   ABAP_BOOL TYPE C LENGTH 1.


CONSTANT :    ABAP_FALSE     TYPE ABAP_BOOL VALUE ' '.

If sy-subrc <> 0.

       RESULT = abap_false.

     Else.

       RESULT = wa_itab-flag.

     Endif.


Hope this helps.

Read only

0 Likes
1,090

I guess you need space in between 2 variable1 and lenght right ?

RESULT = space is working for me.


but don't know the reason.

Pls let me know how can I help you  ?

Thanks,

Aarti

Read only

0 Likes
1,090

Thanks You so much Gaurav. You are a star. I have fixed it and the report is showing blank values without NA.

Thanks every body for their answers. But the winner is Gaurav with complete steps.

Cheers

DR

Read only

Former Member
0 Likes
1,090

Hi DR,

can you try to define a constant with value space & assign that constant here in above code?

Br,

Amit

Read only

0 Likes
1,090

Hi Amit,

I am a SAP BI Consultant and not an ABAP'er. How to do that ?

Can you please provide the code, if we assign constant into the result when sy-subrc <> 0 then we are in a problem. It should be either a space when sy-subrc <> 0 and if its 0 it will have the result (flag) populated. We cannot populate any other value other than space in it ? Did I provide you clear info ?

Please update if you need more info.

Thank You

DR

Read only

0 Likes
1,090

Try this.

CONSTANTS: lv_val TYPE char2 (or string) VALUE ' ' .

If sy-subrc <> 0.
       RESULT = lv_val.
     Else.
       RESULT = wa_itab-flag.
     Endif.



Br,

Amit

Read only

Former Member
0 Likes
1,090

Hi,

Please change data type of field and use it.

It might get solved.

Regards,

Dular Sharma.