Upgrade - Abap Role
Upgrade - Abap Role
Upgrade - Abap Role
SY-SUBRC = 0: The file was opened. SY-SUBRC = 8: The file could not be opened.
c. To make your programs portable to different operating systems, use the function module FILE_GET_NAME, which returns the system-dependent name for an abstract file name. You can define file names using the transaction FILE.
The system automatically performs an authorization check. If this check fails, a runtime error occurs. You can prevent this by checking the authorization in advance using the function module AUTHORITY_CHECK_DATASET.
DATA: file TYPE string VALUE `test.dat`, result TYPE string. OPEN DATASET file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT. TRANSFER `1234567890` TO file. CLOSE DATASET file. OPEN DATASET file FOR UPDATE IN TEXT MODE ENCODING DEFAULT AT POSITION 2. TRANSFER `ABCD` TO file. CLOSE DATASET file. OPEN DATASET file FOR INPUT IN TEXT MODE ENCODING DEFAULT. WHILE sy-subrc = 0. READ DATASET file INTO result. WRITE / result. ENDWHILE. CLOSE DATASET file.
Sap Technical.
REPORT ZDOWNLOAD_APPL_DEMO. TYPES : BEGIN OF ST_DEMO, REG_NO(10) TYPE C, NAME(20) TYPE C, ADDR(20) TYPE C, END OF ST_DEMO. DATA : WA_DEMO TYPE ST_DEMO, IT_DEMO TYPE TABLE OF ST_DEMO, L_FNAME TYPE STRING . PARAMETERS: P_FNAME(128) TYPE C DEFAULT '\usr\sap\SRI\SYS\src\DOWN.TXT' OBLIGATORY. L_FNAME = P_FNAME. WA_DEMO-REG_NO = '100001'. WA_DEMO-NAME = 'ANAND'. WA_DEMO-ADDR = 'NAGARKOVIL'. APPEND WA_DEMO TO IT_DEMO. WA_DEMO-REG_NO = '100002'. WA_DEMO-NAME = 'VIKRAM'. WA_DEMO-ADDR = 'CHENNAI'. APPEND WA_DEMO TO IT_DEMO. OPEN DATASET L_FNAME FOR OUTPUT IN TEXT MODE ENCODING DEFAULT. WRITE :5 'REG NUM',16 'NAME',37 'ADDRESS' . LOOP AT IT_DEMO INTO WA_DEMO. IF SY-SUBRC = 0. TRANSFER WA_DEMO TO L_FNAME. WRITE :/5 WA_DEMO-REG_NO,16 WA_DEMO-NAME,37 WA_DEMO-ADDR. ENDIF. ENDLOOP.
TYPE 2: TYPE X ERRORS: When creating files from within ABAP(SAP) programs it is sometimes necessary to insert Hex codes in-order for the target application software to deal with the file appropriately. For example if you are creating a excel spreadsheet file you will need to insert the hex code for 'TAB' so that excel knows where each new column starts. Type 'X' and 'Xstring' cannot be used in the upgraded version i.e. 6.0. All the Type X data needs to be converted to Character Type. The following table can be checked to see the conversion of hexadecimal data to character type: " ERROR: x_crlf must be a character-like data object (data type C, N, D, T, or STRING). 2.1 Example: DATA: x_crlf(2) TYPE x VALUE '0D0A'. "In 4.6 version The solution for such issues is :
CLASS: cl_abap_char_utilities DEFINITION LOAD. DATA: x_crlf TYPE string, _x_cr TYPE c VALUE cl_abap_char_utilities=>NEWLINE,_ _x_lf type c value cl_abap_char_utilities=>CR_LF._ CONCATENATE x_cr x_lf INTO x_crlf.