ABAP Syntax for Read in SAP Programming

ABAP programming is used for SAP is used to extract data from R/3 data base and here we are going to learn about syntax of key word READ. Our previous discussion is regarding sap syntax for provide.





READ Determine calendar information


The READ CALENDAR statement exists only in the R/2 System.
In the R/3 System, the following function modules are substituted:

· DATE_COMPUTE_DAY : Returns the day for a date
· DATE_CONVERT_TO_FACTORYDATE : Returns the factory calendar date for a date
· DATE_GET_WEEK : Returns the week in which a date occurs
· EASTER_GET_DATE : Returns the Easter dates for a year
· FACTORYDATE_CONVERT_TO_DATE : Returns the date for a factory calendar date
· HOLIDAY_CHECK_AND_GET_INFO : Checks whether a date is a public holiday and, if necessary, returns information
· WEEK_GET_FIRST_DAY : Returns the first day of a week

READ - Read a file

Basic form

READ DATASET dsn INTO f.

Addition

... LENGTH len

Effect

Reads a record from the sequential file specified in dsn (a field or a literal) and stores it in the field f (usually a field string).

· Binary mode (addition IN BINARY MODE in the OPEN DATASET statement:
Read from file in length of field f .

· Text mode (addition IN TEXT MODE in the OPEN statement):

Read a line.

If the specified file is not open, READ DATASET attempts to open the file dsn ( IN BINARY MODE FOR INPUT or with the specifications of the last OPEN command for this file). Any errors result in the termination of the program.

To read all the records in a file, you are recommended to place READ DATASET in a DO loop that you leave with EXIT .

The return code value is set as follows:

SY-SUBRC = 0 Record read from file.
SY_SUBRC = 4 End of file reached.

Example

Define the field string REC :
DATA: BEGIN OF REC,
TEXT(30),
NUMBER TYPE I,
END OF REC.

Read the file "/usr/test":

DO.
READ DATASET '/usr/test' INTO REC.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
WRITE: / REC-TEXT, REC-NUMBER.
ENDDO.

You can use TRANSFER to output records to a sequential dataset.

· The format of file names depends largely on the operating system. You can access portable programs by using the function module FILE_GET_NAME which returns the physical name for a given logical file name.

Related Posts:

COST CENTER of SAP Actual line items
SAP Finance General Ledger report account balance
Finance general ledger line items SAP ABAP report
General ledger report SAP FINACNE
SAP FICO customer open items report
Customer balance in local currency for SAP FICO
Vendor open items report
SAP Finance abap report for Vendor balance in local currency

1 comment:

  1. This comment has been removed by a blog administrator.

    ReplyDelete