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

If statement

Former Member
0 Likes
1,177

Hi friends,

I want to keep two if conditions.,

1. IF ( zinv_mov-status = 'DI' and zinv_mov-xblnr is initial ).

2. IF not ( zinv_mov-status is initial

and zinv_mov-xblnr is initial ).

Can you tell me what is wrong in the statement.

Regards,

Line

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,149

i am not sure what is your requirement but if you are using like this

IF ( zinv_mov-status = 'DI' and zinv_mov-xblnr is initial ).

IF not ( zinv_mov-status is initial

and zinv_mov-xblnr is initial ).

endif.

endif.

then two ifs are contradictory because in first if you are checking zinv_mov-xblnr must be initial and in the 2nd if you are checking zinv_mov-xblnr must not be initial.

i think you want to do like that..

IF ( zinv_mov-status = 'DI' and zinv_mov-xblnr is initial ).

elseif not ( zinv_mov-status is initial

and zinv_mov-xblnr is initial ).

endif.

correct me if i am wrong and what is your exact requirement...

regards

shiba dutta

11 REPLIES 11
Read only

former_member196280
Active Contributor
0 Likes
1,149

Try to keep the 2 if statement first and first if statement later.

IF not ( zinv_mov-status is initial

and zinv_mov-xblnr is initial ).

IF not ( zinv_mov-status is initial

and zinv_mov-xblnr is initial ).

***********

**************

************

ENDIF.

ENDIF.

Reward points if useful.

Regards,

SaiRam

Read only

Former Member
0 Likes
1,149

Hi

Can you please tell what exactly do you want,after writting the statements as the objective of writing the statement is not clear nothing can be suggested.

Thanks

Read only

Former Member
0 Likes
1,150

i am not sure what is your requirement but if you are using like this

IF ( zinv_mov-status = 'DI' and zinv_mov-xblnr is initial ).

IF not ( zinv_mov-status is initial

and zinv_mov-xblnr is initial ).

endif.

endif.

then two ifs are contradictory because in first if you are checking zinv_mov-xblnr must be initial and in the 2nd if you are checking zinv_mov-xblnr must not be initial.

i think you want to do like that..

IF ( zinv_mov-status = 'DI' and zinv_mov-xblnr is initial ).

elseif not ( zinv_mov-status is initial

and zinv_mov-xblnr is initial ).

endif.

correct me if i am wrong and what is your exact requirement...

regards

shiba dutta

Read only

Former Member
0 Likes
1,149

Hi Line,

What exactly is your requirement.

Just by looking at your IF I can say you should change

2. IF not ( zinv_mov-status is initial

and zinv_mov-xblnr is initial ).

To

<b>IF zinv_mov-status is NOT initial AND

zinv_mov-xblnr is NOT initial</b>.

Regards,

Atish

Read only

Former Member
0 Likes
1,149

Sorry Friends,

I need to select the data on two requirement.,

1. When the user uses the status in the screen

Or

2. When the user uses the status with the invoice number.

Based on this two conditions I need to pick the data from the database table.

Regards,

Line

Read only

0 Likes
1,149

Hi,

do it like this.

IF ( zinv_mov-status = 'DI' and zinv_mov-xblnr is initial ) or not ( zinv_mov-status is initial

and zinv_mov-xblnr is initial ).

endif.

<b>reward if helpful.</b>

rgds,

bharat.

Read only

0 Likes
1,149

Hi Line,

Just paste your code then, I can suggest the required changes.

Regards,

Atish

Read only

0 Likes
1,149

Hi there,

Here is my code

*IF zinv_mov-status EQ 'DI' and zinv_mov-xblnr is not initial.

SELECT trans

lifnr

xblnr

bukrs

procese

appdate

usnam

status

FROM zinv_mov INTO CORRESPONDING FIELDS OF

TABLE lt_invmov WHERE clear NE 'CL'

AND status NE 'PV'

OR xblnr EQ zinv_mov-xblnr.

PERFORM vendorname.

SORT lt_invmov BY xblnr.

IF sy-subrc <> 0.

MESSAGE i000(x) WITH 'No Records for processing'.

ENDIF.

  • ENDIF.

IF zinv_mov-status = 'DI'.

SELECT trans

lifnr

xblnr

bukrs

procese

appdate

usnam

status

FROM zinv_mov INTO CORRESPONDING FIELDS OF

TABLE lt_invmov WHERE clear NE 'CL'

AND status NE 'PV'

AND xblnr EQ zinv_mov-xblnr.

IF sy-subrc <> 0.

MESSAGE i000(x) WITH 'No Records for processing'.

ENDIF.

ENDIF.

Regards,

Line

Read only

0 Likes
1,149

Hi Line,

Just change your code as below.

IF zinv_mov-status EQ 'DI' OR inv_mov-xblnr is not initial.

SELECT trans

lifnr

xblnr

bukrs

procese

appdate

usnam

status

FROM zinv_mov INTO CORRESPONDING FIELDS OF

TABLE lt_invmov WHERE clear NE 'CL'

AND status NE 'PV'.

if inv_mov-xblnr is not initial.

DELETE lt_invmov where xblnr NE inv_mov-xblnr.

ENDIF.

PERFORM vendorname.

SORT lt_invmov BY xblnr.

IF sy-subrc <> 0.

MESSAGE i000(x) WITH 'No Records for processing'.

ENDIF.

ENDIF.

Reward points if useful.

Regards,

Atish

Read only

Former Member
0 Likes
1,149

make your status field mandatory so that user must enter one value there.

if zinv_mov-xblnr is initial.

select .... where status = zinv_mov-status.

"or you can specify DI in where as per ur requirement

else.

select .... where status = zinv_mov-status and xblnr = zinv_mov-xblnr .

endif.

regards

shiba dutta

Read only

Former Member
0 Likes
1,149

Hi

you can try this ...

IF ZINV_MOV-STATUS EQ 'DI'.

IF ZINV_MOV-XBLNR IS NOT INITIAL.

SELECT TRANS

LIFNR

XBLNR

BUKRS

PROCESE

APPDATE

USNAM

STATUS

FROM ZINV_MOV INTO CORRESPONDING FIELDS OF

TABLE LT_INVMOV WHERE CLEAR NE 'CL'

AND STATUS NE 'PV'

OR XBLNR EQ ZINV_MOV-XBLNR.

PERFORM VENDORNAME.

SORT LT_INVMOV BY XBLNR.

IF SY-SUBRC <> 0.

MESSAGE I000(X) WITH 'No Records for processing'.

ENDIF.

ELSEIF ZINV_MOV-XBLNR IS INITIAL.

SELECT TRANS

LIFNR

XBLNR

BUKRS

PROCESE

APPDATE

USNAM

STATUS

FROM ZINV_MOV INTO CORRESPONDING FIELDS OF

TABLE LT_INVMOV WHERE CLEAR NE 'CL'

AND STATUS NE 'PV'

AND XBLNR EQ ZINV_MOV-XBLNR.

IF SY-SUBRC <> 0.

MESSAGE I000(X) WITH 'No Records for processing'.

ENDIF.

ENDIF.

ENDIF.

Rewards if useful.

Regards