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

ABAP Command for null value

Former Member
0 Likes
1,871

Hi ,

I am writing an ABAP code in an Infopackage for loading dates which are either null or between 2001 to 2004.

Can anyone Please send me the exact code.

I tried so many ways. But It didnt work. Any help will be appreciated.

Thanks

1 ACCEPTED SOLUTION
Read only

ferry_lianto
Active Contributor
0 Likes
1,367

Hi,

Please try this perhaps it may work ...


L_T_RANGE-SIGN = 'I'.
L_T_RANGE-OPTION = 'CP'.
L_T_RANGE-LOW = '0000000*'.    
APPEND L_T_RANGE.
 
OR

L_T_RANGE-SIGN = 'I'.
L_T_RANGE-OPTION = 'EQ'.
L_T_RANGE-LOW = '00000000'.    
APPEND L_T_RANGE.
 

Regards,

Ferry Lianto

12 REPLIES 12
Read only

Former Member
0 Likes
1,367

Somnething like:


IF   date IS INITIAL OR
   ( date(4) BETWEEN '2001' AND '2004' ).
*
*Your logic here
*
ENDIF.

Rob

Read only

Former Member
0 Likes
1,367

I Just write the logic here.

Data L_date type sy-datum.

If l_date is initial or

L_date+(4) = '2001' or

L_date+(4) = '2002' or

L_date+(4) = '2003' or

L_date+(4) = '2004' ).

write your own logic to trigger.

Endif.

Read only

Former Member
0 Likes
1,367

Thanks a lot!!! but I am very new to ABAP...If you guys can help me some more to make it more clear that would be great. Right now I have this code but It is returning 0 records because the date field is all null.So trying to figure out How to include Null date field .

L_T_RANGE-LOW = 'SPACE'.

L_T_RANGE-SIGN = 'I'.

L_T_RANGE-OPTION = 'EQ'.

APPEND L_T_RANGE.

L_T_RANGE-LOW = '20040101'.

L_T_RANGE-HIGH = '20060101'.

L_T_RANGE-OPTION = 'BT'.

APPEND L_T_RANGE.

Read only

0 Likes
1,367

Do you want the range between 2001 and 2004 or between 2004 and 2006?

Your code looks ok. what's in l_t_range-high in the first case? It should be cleared out.

rob

Read only

0 Likes
1,367

I need range between 2004 and 2006?

Read only

ferry_lianto
Active Contributor
0 Likes
1,367

Hi,

Please try this ...


L_T_RANGE-LOW = SPACE.     "Change here
L_T_RANGE-SIGN = 'I'.
L_T_RANGE-OPTION = 'EQ'.
APPEND L_T_RANGE.

L_T_RANGE-LOW = '20040101'.
L_T_RANGE-HIGH = '20060101'.
L_T_RANGE-OPTION = 'BT'.
APPEND L_T_RANGE. 

Regards,

Ferry Lianto

Read only

0 Likes
1,367

Ferry ,

It Did'nt work. In my tables all the dates in that specific date range have null values , so Its returning 0 records , So what I am trying to write a code for is

return null date records and between 2004 to 2006.

Thanks

Read only

ferry_lianto
Active Contributor
0 Likes
1,367

Hi,

What is the value for your null date field?

Is it space or '00000000'?

Regards,

Ferry Lianto

Read only

0 Likes
1,367

it is 00000000

Read only

0 Likes
1,367

When initializing fields or structures, it's better to use the CLEAR key word. that way, all fields in the structure will be initialized to their proper values. Try this:


CLEAR l_t_range.
l_t_range-sign = 'I'.
l_t_range-option = 'EQ'.
APPEND l_t_range.

CLEAR l_t_range.
l_t_range-low = '20040101'.
l_t_range-high = '20060101'.
l_t_range-option = 'BT'.
APPEND l_t_range.

Rob

Read only

ferry_lianto
Active Contributor
0 Likes
1,368

Hi,

Please try this perhaps it may work ...


L_T_RANGE-SIGN = 'I'.
L_T_RANGE-OPTION = 'CP'.
L_T_RANGE-LOW = '0000000*'.    
APPEND L_T_RANGE.
 
OR

L_T_RANGE-SIGN = 'I'.
L_T_RANGE-OPTION = 'EQ'.
L_T_RANGE-LOW = '00000000'.    
APPEND L_T_RANGE.
 

Regards,

Ferry Lianto

Read only

0 Likes
1,367

Ferry ,

Thanks a lot...the second one worked.....

Thanks a lot