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

Check 1 = 2

Former Member
0 Likes
2,704

Hi,

Can anyone explain the <b>'1 = 2'</b> which you can find in SAP sources (for example : SAPDBVAV, SAPDBVLV, SAPF011) ?

Regards,

Rob Makelaar

The Netherlands

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,765

It looks to me that it is being used as a way of exiting the FORM. For example, in the program SAPF011.



FORM VORTRAG_AUF_GLEICHES_KONTO.

  IF CONTR-EXIST = SPACE.
    MIGTAB-RACCT = EXTR-RACCT.
    MIGTAB-BUKRS = EXTR-BUKRS.
    CASE CONTR-ERROR.
      WHEN 'SKA1'. MIGTAB-TEXT1 = TEXT-007.
      WHEN 'SKB1'. MIGTAB-TEXT1 = TEXT-008.
      WHEN 'T001'. MIGTAB-TEXT1 = TEXT-026.
    ENDCASE.
    COLLECT MIGTAB.
    CHECK 1 = 2.
  ENDIF.


If it goes inside this IF statement, then it will never go any further in the FORM, it will exit at the CHECK 1 = 2.

Not sure why they didn't just use the "EXIT" statement.

Regards,

Rich Heilman

Hi,

Can anyone explain the <b>'1 = 2'</b> which you can find in SAP sources (for example : SAPDBVAV, SAPDBVLV, SAPF011) ?

Regards,

Rob Makelaar

The Netherlands

7 REPLIES 7
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,766

It looks to me that it is being used as a way of exiting the FORM. For example, in the program SAPF011.



FORM VORTRAG_AUF_GLEICHES_KONTO.

  IF CONTR-EXIST = SPACE.
    MIGTAB-RACCT = EXTR-RACCT.
    MIGTAB-BUKRS = EXTR-BUKRS.
    CASE CONTR-ERROR.
      WHEN 'SKA1'. MIGTAB-TEXT1 = TEXT-007.
      WHEN 'SKB1'. MIGTAB-TEXT1 = TEXT-008.
      WHEN 'T001'. MIGTAB-TEXT1 = TEXT-026.
    ENDCASE.
    COLLECT MIGTAB.
    CHECK 1 = 2.
  ENDIF.


If it goes inside this IF statement, then it will never go any further in the FORM, it will exit at the CHECK 1 = 2.

Not sure why they didn't just use the "EXIT" statement.

Regards,

Rich Heilman

Read only

0 Likes
1,765

maybe the return code is different

Read only

FredericGirod
Active Contributor
0 Likes
1,765

It's a not possible equality, so you will stop at this point and exit the form. It's like an EXIT command.

The people who make this code like to play

Regards

Frédéric

Read only

Former Member
0 Likes
1,765

It's a way to not execute the code of program after the control.

In a routine like FORM you could also write EXIT instead of CHECK 1 = 2 or...... CHECK 'BATMAN' = 'ROBIN'.... eh! eh! eh!

Read only

Former Member
0 Likes
1,765

Hi,

I suppose that this CHECK performs always a negative result.

"CHECK with a negative outcome terminates the current loop pass and goes back to the beginning of the loop to start the next pass, if there is one. "

Svetlin

Read only

0 Likes
1,765

Please award points for helpful answers and mark this post as solved. Thanks.

Regards,

Rich Heilman

Read only

sergey_korolev
Active Contributor
0 Likes
1,765

Sometimes it used to make possible searching something (e.g. messages) via <b>where-used</b> list. E.g. there are places where they collect messages into some application log without issueing it by MESSAGE statement, and obviously in that case you cannot find particular message via where-used list. And certainly something like

IF 1 = 2.
  MESSAGE ....
ENDIF.

can help somehow.