Application Development 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: 

What SY-SUBRC type be allocated if PARAMETERS have no input value?

0 Kudos

Hi experts.

I want to know SY-SUBRC type when PARAMETERS have no input value(just implement without input on parameters.

I wanna print two different MESSAGE types with dividing conditions into two sorts that one is parameter have wrong input value and other is have no input value.

Best Regard.

1 ACCEPTED SOLUTION

vinita_kasliwal
Active Contributor

HI There

What does your question mean

If you have 2 parameter check if a parameter is initial or not or check if parameter = X

Why do you need SY-SURBC to work for that?

Maybe share your code if this is not what you are looking for?

Regards

Vinita

10 REPLIES 10

AlexGourdet
Community Manager
Community Manager
0 Kudos

Thank you for visiting SAP Community to get answers to your questions.

Since you're asking a question here for the first time, I'd like to recommend you with the following steps so you can get the most out of your community membership:

I also recommend that you include a profile picture. By personalizing your profile, you encourage readers to respond: https://developers.sap.com/tutorials/community-profile.html.

I hope you find this advice useful, and we're happy to have you as part of SAP Community!

All the best,
-Alex

vinita_kasliwal
Active Contributor

HI There

What does your question mean

If you have 2 parameter check if a parameter is initial or not or check if parameter = X

Why do you need SY-SURBC to work for that?

Maybe share your code if this is not what you are looking for?

Regards

Vinita

0 Kudos

HI

Thanks for your replying.

I think i set parameters condition with not ordinary method.

And i just solved the problem with your advice 'check if a parameter is initial or not or check if parameter = X'.

I set condition with " IF PARAMETER = ' ' " and it working.

Thank you Vinita

0 Kudos

And please tell me advice against my syntax if have problem. I actually think this syntax is not practical.

Sandra_Rossi
Active Contributor
0 Kudos

I don't understand, why do you want to use SY-SUBRC, just to test values of a selection screen parameter?

It will be easier to answer if you also show your code.

0 Kudos

Hi expert.

I just started studying ABAP with only myself..

So apolozize against my low quality question and please understand even if my question is little bit weird.

and this is my syntax for print error message. I actally think this syntax is not practical so if you have advices

against my syntax please tell me.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
PARAMETERS:
AC_NUM TYPE ACDOCA-BELNR VALUE CHECK,
COM_CODE TYPE ACDOCA-RBUKRS VALUE CHECK,
FISC_YR TYPE ACDOCA-GJAHR VALUE CHECK.

SELECTION-SCREEN END OF BLOCK b1.

AT SELECTION-SCREEN.

SELECT ACDOCA~BELNR,
ACDOCA~RBUKRS,
ACDOCA~GJAHR
FROM ACDOCA
INTO CORRESPONDING FIELDS OF TABLE @vtb1_account_doc.



READ TABLE vtb1_account_doc TRANSPORTING NO FIELDS WITH KEY
RBUKRS = COM_CODE.
IF COM_CODE = ''.
MESSAGE E003(ZF1) WITH TEXT-003.
ELSEIF SY-SUBRC = 0.
READ TABLE vtb1_account_doc TRANSPORTING NO FIELDS WITH KEY
BELNR = AC_NUM.
IF SY-SUBRC = 0.
READ TABLE vtb1_account_doc TRANSPORTING NO FIELDS WITH KEY
GJAHR = FISC_YR.
IF SY-SUBRC = 0.
MESSAGE S001(ZF1) WITH TEXT-002.
ELSEIF FISC_YR = ''.
MESSAGE E001(ZF1) WITH TEXT-004.
EXIT.
ELSE.
MESSAGE E004(ZF1) WITH TEXT-006.
EXIT.
ENDIF.
ELSEIF AC_NUM = ''.
MESSAGE E002(ZF1) WITH TEXT-005.
EXIT.
ELSE.
MESSAGE E004(ZF1) WITH TEXT-006.
EXIT.
ENDIF.
ELSE.
SY-SUBRC = 4.

ENDIF.

0 Kudos

I also add screenshot systax.

Sandra_Rossi
Active Contributor

Please select your code and press the button [CODE], which makes the code appear colored/indented, it will be easier for people to look at it. Thank you!

Sandra_Rossi
Active Contributor

I think I can't help you about the logic you want to implement but I can advise about ABAP:

  • Don't use SELECT without WHERE due to performance risks (you can avoid WHERE only for very small customizing tables)
  • Don't change values of system fields (like SY-SUBRC)
  • An error message stops the processing so no need to indicate EXIT after MESSAGE e.
  • Don't do useless ABAP code like move READ TABLE WITH KEY rbukrs = com_code and after testing the value of com_code
  • Avoid using TEXT-002 because of legibility, prefer 'your text'(002)

0 Kudos

Hi expert!

I appreciate about your point out!

i would keep your advice in my mind and coding.

thank you very much.