Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

SY-SUBRC, Ranges

Hi ALL,

1. What is mean by sy-subrc.?

2.What is subrc value for that?

3. If sy-subrc = 0 or 2 or 4 or 8 given like this what it happend when it calling ?

4.What is difference between 0, 2 , 4, 8 ?

Ranges :

1.What is ranges in ABAP ? how we call in program?

2.What is select-option ? how we give here number range?

3.How do we create an internal table for ranges?

4.What is SAP-Memory and ABAP-Memory?

Former Member
Former Member replied

HI,

Go through this info.

What are the difference between SELECT-OPTIONS & RANGES?

Here both SELECT-OPTIONS & RANGES works for the same purpose. They both are used for the range selection from selection screen. The main diff. between them is, while we use SELECT-OPTIONS system implicitly creates the select options internal table which contains the fields of SIGN,OPTION,LOW & HIGH. But in case of RANGES, this internal table should be defined explicitly.

Eg. to SELECT-OPTIONS :

-

-


REPORT YARSELECT.

TABLES YTXLFA1.

SELECT-OPTIONS : VENDOR FOR YTXLFA1-LIFNR.

INITIALIZATION.

VENDOR-LOW = 1000. " It specifies the range starting value.

VENDOR-HIGH = 2000. " It specifies the range ending value.

VENDOR-OPTION = 'BT'. " specifies ranges value is in between.

VENDOR-SIGN = 'I'. "specifies both inclussive.

APPEND VENDOR.

- - -

- - -

SELECT LIFNR LAND1 NAME1 FROM LFA1 INTO TABLE ITAB

WHERE LIFNR IN VENDOR.

Eg. to RANGES:

-

-


REPORT YARRANGE.

TABLES YTXLFA1.

RANGES: VENDOR FOR YTXFLA1-LIFNR.

- - -

- - --

- - -

SELECT LIFNR LAND1 NAME1 FROM LFA1 INTO TABLE ITAB

WHERE LIFNR IN VENDOR.

Here with RANGES user has to design an internal table with fields -

SIGN,OPTION,LOW and HIGH EXPLICITLY.

-

-


Example:

select-options: bukrs for zstock-bukrs.

Should the user fill in 'ABFI' in BUKRS on the selection screen, BUKRS will look like this:

IEQABFI

This is because BUKRS is set as a table as follows:

begin of bukrs occurs 0,

SIGN(1) type c,

OPTION(2) type c,

LOW like bukrs,

HIGH like bukrs,

end of bukrs.

Now, when you create the following range, it will have the exact same fields set inside its table:

Ranges: bukrs for zstock-bukrs.

The difference is, because ranges doesn't show on the selection screen, you will have to fill it yourself, meaning you will have to fill bukrs-sign, bukrs-option, bukrs-low & bukrs-high all manually.

Some tips:

Sign is always I (for Include) or E (for Exclude)

Option can be a whole range, which includes:

EQ (Equal)

BT (Between))

CP (Contain Pattern)

So let's say you want to have the range check for all company codes not starting with AB, you will set your code as follow:

ranges: bukrs for zstock-bukrs.

bukrs-sign = 'E'. "Exclude

bukrs-option = 'CP'. "Pattern

bukrs-low = 'AB*'. "Low Value

bukrs-high = ''. "High Value

append bukrs.

Always remember to APPEND your range when you fill it, as the WHERE clause checks against the lines of the range table, not against the header line.

Hope this explains it well enough.

-

-


What does SIGN "I" & "E" mean?

The "I" stands for Include, and the "E" for Exclude.

The easiest way to learn how the range selections work is, create the following dummy program:

report dummy.

tables: mara.

select-options: matnr for mara-matnr.

start-of-selection.

loop at matnr.

write: / matnr-sign,

matnr-option,

matnr-low,

matnr-high.

endloop.

Run this program, and fill in a lot of junk into MATNR. Fill in some includes, some excludes, some ranges, etc., and you will soon realise how the system builds ranges (select-options). Once you know that, you can fill your own ranges quickly and efficiently.

-

-


abap memory is local memory,

sap memory is global memory

SAP Memory

SAP memory is a memory area to which all main sessions within a SAPgui have access. You can use SAP memory either to pass data from one program to another within a session, or to pass data from one session to another. Application programs that use SAP memory must do so using SPA/GPA parameters (also known as SET/GET parameters). These parameters can be set either for a particular user or for a particular program using the SET PARAMETER statement. Other ABAP programs can then retrieve the set parameters using the GET PARAMETER statement. The most frequent use of SPA/GPA parameters is to fill input fields on screens

ABAP/4 Memory

ABAP memory is a memory area that all ABAP programs within the same internal session can access using the EXPORT and IMPORT statements. Data within this area remains intact during a whole sequence of program calls. To pass data

to a program which you are calling, the data needs to be placed in ABAP memory before the call is made. The internal session of the called program then replaces that of the calling program. The program called can then read from the ABAP memory. If control is then returned to the program which made the initial call, the same process operates in reverse.

-

-


sy-subrc

It is a universal indicator. Its value is based on whether a certain ABAP statement was successful or not. For example, if a SELECT statement is sucessful, the value of SY-SUBRC will be 0, otherwise, it will be 4.

Return Value

SY-SUBRC

Return value set by the following ABAP statements. In general, a content of 0 means that the statement was executed without problems.

· ASSIGNsets SY-SUBRC to 0 if assignment to field symbol is possible, otherwise 4.

· ASSIGN dref->* sets SY-SUBRC to 0 if dereferencing is possible, otherwise 4.

· AUTHORITY-CHECK sets SY-SUBRC to 0 if the user has the necessary authorization, otherwise 4, 8, 12, 16, 24, 28, 32, or 36 depending on the cause.

· CALL DIALOG with USING sets SY-SUBRC to 0, if processing was successful, otherwise 0.

· CALL FUNCTION sets SY-SUBRC according to the exception handling.

· CALL METHOD sets SY-SUBRC according to the exception handling.

· CALL SELECTION-SCREEN sets SY-SUBRC to 0 if the user chose Enter or Execute and 4 if the user chose Cancel.

· CALL TRANSACTION with USING sets SY-SUBRC to 0 if processing was successful, otherwise 0.

· CATCH SYSTEM-EXCEPTIONS sets SY-SUBRC if there are runtime errors after the ENDCATCH statement. The value is specified in the program.

· COMMIT WORK sets SY-SUBRC to 0.

· COMMIT WORK AND WAIT sets SY-SUBRC to 0 if update was successful, otherwise 0.

· COMMUNICATION INIT DESTINATION … RETURNCODE sets SY-SUBRC as specified.

· CONCATENATE sets SY-SUBRC to 0 if the result fits into target variable, otherwise 4.

· CREATE OBJECT sets SY-SUBRC if the exceptions of the instance constructor are handled.

· CREATE OBJECT in OLE2 sets SY-SUBRC to 0 if an external object was created, otherwise 1,2, 3 with different causes.

· DELETEsets SY-SUBRC to 0 if operation was successful, otherwise 4 or 0 depending on cause.

· DEMAND … MESSAGES INTO sets SY-SUBRC to 0 if a message table is empty, otherwise 0.

· DESCRIBE LIST sets SY-SUBRC to 0 if row or list exists, otherwise 4 or 8.

· EXEC SQL - ENDEXEC sets SY-SUBRC to 0 in almost all cases. Only if no set was read with FETCH is SY-SUBRC 4.

· FETCHsets SY-SUBRC to 0 if at least one row was read, otherwise 4.

· GENERATE SUBROUTINE POOL sets SY-SUBRC to 0 if generation was successful, otherwise 8.

· GET CURSOR sets SY-SUBRC to 0 if the cursor is correctly positioned, otherwise 4.

· GET PARAMETER sets SY-SUBRC to 0 if value found in SAP Memory, otherwise 4.

· IMPORTsets SY-SUBRC to 0 if import of data objects was successful, otherwise 4.

· INSERTsets SY-SUBRC to 0 if operation was successful, otherwise 4.

· LOAD REPORT sets SY-SUBRC to 0 if operation was successful, otherwise 4 or 8 depending on cause.

· LOOPsets SY-SUBRC to 0 if loop over extract was passed at least once, otherwise 4.

· LOOP ATsets SY-SUBRC to 0 if loop over internal table was passed at least once, otherwise 4.

· MODIFYsets SY-SUBRC to 0 if operation was successful, otherwise 4.

· MODIFY LINE sets SY-SUBRC to 0 if list row was changed, otherwise 0.

· MODIFYsets SY-SUBRC to 0 if operation was successful, otherwise 4.

· OLE2 automation, bundled commands set SY-SUBRC to 0 if all were successfully executed, otherwise 1, 2, 3, 4 depending on cause.

· OPEN DATASET sets SY-SUBRC to 0 if the file was opened, otherwise 8.

· Open SQL commands set SY-SUBRC to 0 if operation was successful, otherwise 0.

· OVERLAYsets SY-SUBRC to 0 if at least one character is overlayed, otherwise 4.

· READ DATASET sets SY-SUBRC to 0 if the read operation was successful, otherwise 4 or 8 depending on cause.

· READ LINE sets SY-SUBRC to 0 if list row exists, otherwise 0.

· READ TABLE sets SY-SUBRC to 0 if the table row was found, otherwise 2, 4, 8 depending on cause.

· REPLACEsets SY-SUBRC to 0 if search string could be replaced, otherwise 0.

· ROLLBACK WORK always sets SY-SUBRC to 0.

· SCROLLsets SY-SUBRC to 0 if scrolling in list successful, otherwise 4 or 8 depending on cause.

· SEARCHsets SY-SUBRC to 0 if search string was found, otherwise 4.

· SELECTsets SY-SUBRC to 0 if at least one row was read, otherwise 4 or even 8 with SELECT SINGLE FOR UPDATE.

· SET COUNTRY sets SY-SUBRC to 0 if country ID was found in table T005X, otherwise 4.

· SET BITsets SY-SUBRC to 0 if bit was set, otherwise 0.

· SET TITLEBAR sets SY-SUBRC to 0 if title exists, otherwise 4.

· SHIFT … UP TO sets SY-SUBRC to 0 if position was found in character string, otherwise 4.

· SPLITsets SY-SUBRC to 0 if size of target fields is sufficient, otherwise 4.

· UPDATEsets SY-SUBRC to 0 if operation successful, otherwise 4.

· WRITE … TO sets SY-SUBRC to 0 if assignment successful, otherwise 4.

Regards,

KK

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question