This action might not be possible to undo. Are you sure you want to continue?
Defining a DATA: Syntax: DATA var[(length)] [TYPE type] [DECIMALS number] [VALUE initial value] DATA var LIKE table-field [VALUE initial value]. 2. Grouping the variables using RECORDS: Syntax: DATA BEGIN OF record name. DATA field1 TYPE. DATA field2 TYPE. . . DATA fieldn TYPE. DATA END OF record name. 1. INCLUDE STRUCTURE: Syntax: DATA BEGIN OF record name. INCLUDE STRUTURE <database table name>. DATA END OF record name. 4.User Defined DATA TYPES: Syntax: TYPES name[(length)] [TYPE type] [DECIMALS number] TYPES name LIKE table-field. TYPES: BEGIN OF rectyp. : TYPES END OF rectyp. (eg). TYPES Bank_Acct Type C. DATA Cust-Acc TYPE Bank_Acct. DATA Perso-Acc TYPE Bank_Acct. 5.CONSTANTS: Syntax: CONSTANTS var[(length)] [TYPE type] [DECIMALS number] VALUE initial value [IS INITIAL]. CONSTANTS var LIKE table-field VALUE initial value [IS INITIAL]. CONSTANTS: BEGIN OF rec. ……… END OF rec.
Page 1 of 16
Syntax: MOVE value TO var. 9.RUNTIME PARAMETERS.Formatting Commands: Syntax: FORMATT [INTENSIFIED] [INTENSIFIED OFF](for making text appear Bold) [COLOR color] [COLOR OFF] [INVERSE] [INVERSE OFF] (to make background color as foreground color and vice-versa) [RESET]. 2.RANGES: Syntax: RANGES var FOR field [DEFAULT val] [DEFAULT val option] [DEFAULT [NOT] val TO val] 8. Syntax: a. 2. MOVE P_INT_EMP TO W_INT_EMP. 3. ( To skip few lines). 5. b. SKIP & POSITION: Syntax: SKIP.SELECT – OPTIONS: Syntax: SELECT–OPTIONS var FOR field [DEFAULT val] [DEFAULT val option] [DEFAULT [NOT] val TO val] [MEMORY ID id] [MATCHCODE OBJECT object] [LOWER CASE] [NO INTERVALS] [NO EXTENSION] [OBLIGATORY]. PARAMETERS param[(length)] [TYPE type] [LIKE field] [DEFAULT val] [LOWER CASE] [AS CHECKBOX] [RADIOBUTTON GROUP num] [OBLIGATORY].FIELD – SYMBOLS: Syntax: FIELD–SYMBOLS <fs>. Page 2 of 16 .6. Var = value.Displaying and Printing Data (Formatting ) : 1.Assigining Values To Variables Using MOVE. 7. WRITE: Syntax: WRITE /column position(length) data. POSITION n. (Decides where the position of the cursor is to be placed) 2. Displaying MESSAGE: Syntax: MESSAGE message type message number [WITH text]. Advanced Features of WRITE: Syntax: WRITE filed [USING EDIT MASK mask] [USING NO EDIT MASK mask] [NO-ZERO] [NO-SIGN] [DD/MM/YY] [DD/MM/YYYY] [MM/DD/YY] [MM/DD/YYYY] [CURRENCY currency].
TRANSLATE var to LOWER CASE. Manipulating With Strings:. SHIFT var UP TO character [CIRCULAR] [RIGHT] [LEFT].Working With Numeric Data: Syntax: COMPUTE var = expression. 2. MULTIPLY -CORRESPONDING rec1 BY rec1. ADD value TO var. SHIFT var BY n PLACES [CIRCULAR] [RIGHT] [LEFT]. • SHIFT Syntax: SHIFT var [CIRCULAR] [RIGHT] [LEFT]. [only var3] • REPLACE Syntax: REPLACE string1 WITH string2 INTO temp. (var = var * value) DIVIDE value BY var. Manipulating Data. (var = var + value) SUBTRACT value FROM var. SHIFT c RIGHT DELETING TRAILING val. DIVIDE-CORRESPONDING rec1 BY rec1. • TRANSLATE Syntax: TRANSLATE var to UPPER CASE.3. • SUBSTRINGS: Syntax: Var+offset(length). TRANSLATE var USING string. (eg) varb = ‘123456’ MOVE ‘x’ to varb+3(2) will give the o/p 123x_6. Using CORRESPONDONG Command. 1. (var = var . SUBTRACT-CORRESPONDING rec1 FROM rec1. Page 3 of 16 . ADD-CORRESPONDING rec1 TO rec1. SHIFT c LEFT DELETING LEADING val.) • OVERLAY Syntax: OVERLAY var1 WITH var2.value) MULTIPLY value BY var.[LENGTH len] • SEARCH Syntax SEARCH var FOR string [ABBREVIATED] [STARTING AT num] [ENDING AT num] [AND MARK] . (var = var / value) Using Sequential ADD: ADD field1 then field2 UNTIL fieldn [TO var] [GIVING var]. ( To replace a single character with another.
the OCCURS parameter is of no significance. CP (Contains Pattern). F2 TYPE N. CS (Contains String) 4. READ TABLE ITAB INTO WA. = ‘25’. SPLIT str AT char INTO TABLE itab. F1 TYPE C. Page 4 of 16 . CLEAR PERSON. DATA: END OF ITAB. • CONCATENATE Syntax: CONCATNATE var1 var2 var3 into var4 [SEPARATED BY char] • CONDENCE Syntax: CONDENCE var [NO-GAPS]. = ‘MICHAEL’. END OF LINETYPE. … varn. To read a record from the Internal table READ TABLE ITAB. If necessary. Clear the record from the header line. var2. Insert a record into the internal table. you can increase the size later. SORT ITAB BY f1 f2 …fn. CA (Contains Any) 3.• SPLIT Syntax: SPLIT str AT char INTO var1. READ TABLE ITAB WITH KEY K1 = V1 K2 = V2 … KN=VN READ TABLE ITAB INDEX idx. The OCCURS parameter n defines how many tables lines are created initially. Otherwise. NAME (25) TYPE C. 6 Working With Internal Tables: type 1: DATA: BEGIN OF ITAB OCCURS N. To Sort an Internal table SORT ITAB. AGE TYPE I. DATA: PERSON LIKE LINETYPE OCCURS 20 WITH HEADER LINE Inserting a record to Internal table PERSON-NAME PERSON-AGE APPEND PERSON. DATA: BEGIN OF LINETYPE. 4 Using Conditional Operators: Comparing Character Fields: 1. CO (Contains Only) 2.
T-BLNCE. ENDLOOP. the new line is taken from the contents of the explicitly specified work area wa . END OF T. Note If either one of the additions " FROM n1 " or " TO n2 " is missing. Appends a new line to the end of the internal table itab . Page 5 of 16 . To append a record into the internal table APPEND [wa TO|INITIAL LINE TO] itab. APPEND LINES OF itab1 [FROM idx1] [TO idx2] TO itab2. Example Output table entries 7 and 8: DATA: BEGIN OF T OCCURS 100. BAREA (5). ENDLOOP. BLNCE (5). LOOP AT T FROM 7 TO 8. ENDLOOP. T-BLNCE. Places all internal table entries from the entry with the index ( SY-TABIX ) = n1 to the entry with the index = n2 inclusive in the output area in turn.SORT ITAB DESCENDING SORT ITAB ASCENDING To Loop through the internal table. CHECK T-BAREA > 0. LOOP AT ITAB INTO WA. WRITE: / T-BAREA. LOOP AT INTAB WHERE log exp. which has the same effect as: LOOP AT T. then the table is processed either from the first entry or up to the last entry (according to what is missing). LOOP AT T WHERE BAREA > 0. If you specify wa TO . Example. APPEND [wa TO] itab SORTED BY f. T-BLNCE. LOOP AT ITAB. LOOP AT ITAB FROM n1 TO n2. WRITE: / T-BAREA. WRITE: / T-BAREA.
Note By comparing the values of SY-TABIX before and after the APPEND statement. it ends with the last line of itab1. the total number of entries from both tables. After the APPEND . ITAB2 TYPE I OCCURS 100. If there is no TO specification. the system field SY-TABIX contains the index of the newly added table entry. the new line is taken from the internal tbale itab . After the APPEND . the system field SY-TABIX contains the index of the last table entry appended. APPEND 2 TO ITAB1.If you use INITIAL LINE TO . Append a blank line or a line with its initial value to the above list: APPEND INITIAL LINE TO CUSTOMER Type 2: APPEND LINES OF itab1 [FROM idx1] [TO idx2] TO itab2. Effect Appends the internal table itab1 or an extract from itab1 to the end of the internal table itab2. APPEND 3 TO ITAB1. If there is no FROM specification. Page 6 of 16 . you can determine how many lines were appended to the table. APPEND 3 TO ITAB2. APPEND 7 TO ITAB1. it begins with the first line of itab1. i. Example Merge two tables with whole numbers: DATA: ITAB1 TYPE I OCCURS 100. If the specification before itab is omitted. a line filled with the correct value for the type is added.e. APPEND INITIAL LINE TO ITAB2. This means that the complete table is appended if neither a FROM nor a TO is specified. DATA: CUSTOMER LIKE SCUSTOM-ID OCCURS 0. Examples Generate a list with customer numbers: TABLES SCUSTOM. APPEND SCUSTOM-ID TO CUSTOMER. APPEND 5 TO ITAB1. By specifying FROM idx1 or TO idx2 you can restrict the line area taken from the source table itab1.
Effect Inserts the new entry into table and re-sorts the table by the sub-field f in descending order. This entry now appears in the second table line (after 'big' and before 'small' ). COMPANIES-NAME = 'small'. Note Performance This variant is 3 to 4 times faster than using a LOOP to process the source table and append the entries line-by-line to the target table. COMPANIES-SALES = 5. APPEND COMPANIES. The table ITAB2 now contains five lines with the values 3. COMPANIES-SALES = 90. NAME(10). APPEND COMPANIES SORTED BY SALES. it comes from the header line of the internal table itab . the last entry is deleted if the value f of a new entry is greater (particularly suitable for ranked lists). The table now has three (-> OCCURS 3 ) entries. COMPANIES-SALES = 50. COMPANIES-SALES = 10. the new line is taken from the contents of the explicitly specified work area wa . 0. COMPANIES-NAME = 'middle'. Type 3 APPEND [wa TO] itab SORTED BY f. END OF COMPANIES. COMPANIES-NAME = 'big'. If you specify wa TO . The line with the contents 'too small' in the sub-field NAME is deleted from the table because the entry for 'middle' has a greater value in the sub-field SALES . Otherwise. COMPANIES-NAME = 'too small'. SALES TYPE I. 5 and 7. This only makes sense if the table was sorted beforehand. Example DATA: BEGIN OF COMPANIES OCCURS 3. When the number of table entries reaches the OCCURS parameter value. Notes Page 7 of 16 . APPEND COMPANIES. You can only sort by one sub-field. 3.APPEND LINES OF ITAB1 FROM 2 TO 20 TO ITAB2. APPEND COMPANIES.
it should always be filled in this way. Variant 2 DELETE itab INDEX idx.. the area from the start of the table to line idx2 is deleted. the system always searches the entire table. At least one of the two parameters FROM idx1 or TO idx2 should be specified. DELETE itab. If you specify APPEND with the parameter SORTED BY . 2.. Effect The current entry of the internal table itab is deleted in a LOOP loop. Variant 1 DELETE itab. the effect of further update operations on the current entry without an INDEX specification is not guaranteed and may changed in later Releases. If parameter TO is missing. Note The deletion of lines within a LOOP . it is sometimes better to create the table with a simple APPEND and then use SORT to sort in descending ot ascending order afterwards. 3. To Delete a record from the Internal table 1. Therefore. DELETE itab INDEX idx. Page 8 of 16 . SY_SUBRC = 4 The entry does not exist. Note After deleting the current entry in an internal table in a LOOP loop. DELETE itab FROM idx1 TO idx2. Deletes one or more lines from an internal table. Effect Deletes the line area from index idx1 to idx2 from internal table itab . DELETE itab WHERE condition. Effect Deletes the idx entry from the internal table itab . 4. Return code value The is set to 0. ENDLOOP loop is performed in a sequence of loop passes. If parameter FROM is missing.Whenever an internal table is processed with APPEND SORTED BY . Start index idx1 must be greater than 0. Variant 3 DELETE itab FROM idx1 TO idx2. The return code value is set as follows: SY-SUBRC = 0 The entry was deleted. the area from line idx1 to the end of the table is deleted. 5. DELETE ADJACENT DUPLICATES FROM itab.
. TO idx2 Effect Deletes all entries from internal table itab. Additions 1. which satisfies the condition. FROM idx1 2. Variant 4 DELETE itab WHERE condition. Additions 1.. if the entry begins with one of the letters 'A' to 'C' : DATA: BEGIN OF NAMETAB OCCURS 100. NAME(30) TYPE C. DELETE NAMETAB FROM 5 TO 36 WHERE NAME CA 'ABC'. a search is carried out until the end of the table. . a search is carried out from the beginning of the table. TO idx2 Effect Restricts the line area to be investigated to the lines up to index idx2 . If the addition FROM idx1 is missing. The addition FROM must come before the WHERE condition... FROM idx1 Effect The line area to be investigated is restricted to the lines up to index idx1 . Variant 5 DELETE ADJACENT DUPLICATES FROM itab. The return code value is set as follows: SY-SUBRC = 0 At least one entry was deleted. COMPARING ALL FIELDS Page 9 of 16 .. SY_SUBRC = 4 None of the entries were deleted. . Addition 1 ... The addition TO must come before the WHERE condition. ...The return code value is set as follows: SY-SUBRC = 0 At least one entry was deleted. . Example Delete all lines in a name table between lines 5 and 36. .. END OF NAMETAB. SY_SUBRC = 4 None of the entries were deleted. Addition 2 .... If the addition TO idx2 is missing.. 2. COMPARING f1 f2 ...
Addition 2 . SAP SQL. SY_SUBRC = 4 No duplicates exist. 3.. at least one entry deleted. SELECT * FROM BKPS INTO TABLE INT_TAB WHERE BUKRS = 'R300' SELECT SINGLE * FROM BKPS INTO TABLE INT_TAB. If there are n duplicate entries.. no entry deleted. the first entry is retained and the other n . 2. Eg Car Data Element This describes what resides inside the Domain.1 entries are deleted.... SELECT MANDT BUKRS BELNR INTO TABLE INT_TAB FROM BKPF. Fields These are the basic description of under which group data resides... which were compared during duplicate determination 7 Working With Data Dictionary: Domain Is an Object to describe the type of field in which data resides. 4. Various Types of queries: Select: 1. . f2 . Two lines are considered to be duplicated if their default keys match. Addition 1 . The return code value is set as follows: SY-SUBRC = 0 At least one duplicate exists. 5. WHERE BUKRS = 'R300'.DEPTNO) FROM ZBALA_EMP GROUP BY DEPT_NO. COMPARING f1 f2 . Eg Maruthi-800.Effect Deletes neighboring. duplicate entries from the internal table itab . match... eg Sedan 8. SELECT * FROM BKPS INTO TABLE INT_TAB. COMPARING ALL FIELDS Effect Two lines are considered to be duplicates if all fields of the table entries match. Notes The DELETE ADJACENT DUPLICATES statement is especially useful if the internal table itab is sorted by fields (whether in ascending or descending order). Effect Two lines of the internal table itab are considered to be duplicates if the specified fields f1 . SELECT SUM( SALARY ) DEPT_NO INTO (GRPSAL. Page 10 of 16 .
SELECT-OPTIONS IENO FOR ZBALA_EMP-EMPNO.XPOSNR. Insert: 1. SELECT * FROM ZBALA_EMP INTO TABLE INT_TAB WHERE EMPNO IN IENO. INSERT Update: 1. INSERT INTO ZBALA_EMP values INT_BALA. 3.XPLNUM) FROM ( PLAF INNER JOIN VBAP ON PLAF~KDAUF = VBAP~VBELN AND PLAF~KDPOS = VBAP~POSNR ) WHERE VBAP~VBELN = '7262'. ENDSELECT. DATA: END OF INT_TAB. DATA: W_DATAFILENAME(50) TYPE C VALUE 'SARA.6. INCLUDE STRUCTURE ZEMP. DELETE FROM BKPF WHERE BUKRS = 'R300'. Delete: 1. 8. *---------------------------DATA: BEGIN OF INT_TAB OCCURS 0. *---------------------------* Data Selection *---------------------------SELECT * FROM ZEMP INTO TABLE INT_TAB. *---------------------------* Data Declaration.XMATNR. 2. TABLES: ZEMP. SELECT VBAP~VBELN VBAP~POSNR VBAP~MATNR PLAF~PLNUM INTO (XVBELN. DATA: W_MESSAGE(100) TYPE C. ‘P003’. Page 11 of 16 . 2. INSERT 3. ‘P005’ ). UPDATE BKPF FROM INT_TAB. 9. DELETE BKPF FROM INT_TAB.TXT'. Working with External Files: REPORT ZBALA0705_01 . 2. UPDATE BKPF SET BELNR = ‘1111’ WHERE BUKRS = 'R300'. *---------------------------------* Open a file for writing. SELECT * FROM EKPO WHERE EBELN BETWEEN ‘0000454’ AND ‘0000894’ AND WERKS IN ( ‘P002. 7. DELETE BKPF.
*------------------------------* Close the file AND refersh the internal table. COMPUTE R_COUNT = R_COUNT + 1. CLEAR INT_TAB. 13. WHILE SY-SUBRC EQ 0. LOOP AT INT_TAB. WRITE: /20 'FILE READ FROM THE DATA FILE SARA.TXT'. *--------------------------------* open the file for reading *--------------------------------DATA: R_COUNT TYPE I. The commands available are 1. *--------------------------------CLOSE DATASET W_DATAFILENAME. It takes care of all the necessary joins needed to access all the tables. ENDLOOP. READ DATASET W_DATAFILENAME INTO INT_TAB. ENDWHILE. APPEND INT_TAB. 3. WRITE: /20 'No of records :'. *--------------------------------* Close the file.*---------------------------------OPEN DATASET W_DATAFILENAME FOR OUTPUT IN TEXT MODE. CLOSE DATASET W_DATAFILENAME. OPEN DATASET W_DATAFILENAME FOR INPUT IN TEXT MODE MESSAGE W_MESSAGE. Used to limit the amount of data to be returned. GET <table name>. WRITE: /20 INT_TAB. R_COUNT. ENDLOOP. Page 12 of 16 . ULINE. *------------------------------* Loop Thru the Record *------------------------------LOOP AT INT_TAB. CHECK <expression>. GET <table name> LATE. *------------------------------REFRESH INT_TAB. 2. To start with we have to go to the menu option Goto -> Attributes: and set the logical database using it’s 3 character identification we needed. TRANSFER INT_TAB TO W_DATAFILENAME. Working With Logical Database: A Logical Database provides access to a group of tables.
BKPF . Fnam To store the field name. Else use Internal Table. 4.Accounting Document Segment KNA1 . • Determine whether to choose Internal Table or Field-Group to use 1. Data Selection. Dynpro To store Screen Number. BSIS – Accounting : Secondary Index for G/L Accounts. • Choosing the correct table. 15. It simulates the act of a user entering data into an SAP transaction. Writing A BDC Program: A BDC (Batch Data Communication) session is a combination of ABAP/4 programming and built-in SAP functionality. • Specify the Data Types of the data that is to be used.Accounting Document Header BSEG . Transaction Code SHDB Steps Involved in writing a BDC program: BDC-OKCODE BDC-CURSOR. (Contains data from BKPF and BSEG . The system would take the data from an ABAP/4 pgm and feed to an SAP transaction screen by screen. • Determining the Order in which data has to be selected.General Data in Customer Master VBPA . (Default value is ‘X’).) Points to be noted down before starting to write a Report: 1. If data to be retrieved is of very large volume use Field-Group 2. 6.Sales Document : Partner VBRP – Billing : Item Data. 3. Structure of BDCDATA: Program To store the Transaction Name. Writing A Data Extract: 16. 5. Dynbegin To indicate the screen begins. Writing A Report: Some of the tables: 1. 2.14. Page 13 of 16 . Verify the Data 2.
Grants the ability to perform the operation. Always specify your conditions in the where-clause instead of checking with check-statements 2. Performance Tuning: Tips for writing a Sql-Query: 1. CALL TRANSACTION trans [USING bdctab MODE mode] [UPDATE upd] [MESSAGES INTO messtab]. 2. Each Authorization Object will contain up to 10 Authorization Fields and each field will corresponds to a SAP data element. Through BDC_INSERT (Processes multiple transaction at a time). (ST05): 20. BDC_CLOSE_GROUP 17. 4. Syntax: BDC_OPEN_GROUP. SAP Security & Authorization: Security is referred to as Authorizations and the ability to perform an operation in the system is to referred to as Authorization Object. Runtime Analysis Tool. (SE30): 2. ABAP Debugger: 19. SQL Trace.Fval To store the field value. Performance Analysis: 1. Restricts the access to the user. Submitting the BDC Table: 1. Use sub queries instead of using nested Select loops. Each user will contain a master record that contains all the Authorization that he can perform. BDC_INSERT. This command checks whether user is authorized or not. Through CALL TRANSACTION command (Processes one transaction at a time) Syntax. Use a select list or a view instead of Select *. 5. 3. It is always faster to use the Into Table version of a Select statement than to use Append statements. When we r sure that we r going to get only one record it is better use Single Command because it requires one communication with the database system where as the Select-Endselect needs two. Authorizations Authorization Object Authorization Fields User Master Record Authority-Check 18. Page 14 of 16 .
6. 3. SELECTION-SCREEN PUSHBUTTON<format> <name> USER-COMMAND <ucom>. 5. SELECTION-SCREEN END OF BLOCK block1. Server Side 1. Point the client port no 800 in that screen. 4.To Create Push Buttons on the ToolBar: Syntax: SELECTION-SCREEN FUNCTION KEY num. and then create a function module under that group. Go to the Transaction screen se37. 2. Create a function group. Execute to get the output. Remote Function Calls: Steps involved are: Let Us consider the port 800 as server and 810 as Client. 3. Go to the Transaction SM59 Create an RFC Destination under R/3 connection. 2. SELECTION-SCREEN POSITION num.ADVANCED ABAP 1. 2. 2. To Generate Titles and Boxes: Syntax: SELECTION-SCREEN BEGIN OF BLOCK block1 <WITH FRAME> <TITLE title1 ><NO INTERVALS> PARAMETERS SELECTION-SCREEN COMMENT <format> <name> [FOR FIELD fldname] SELECTION-SCREEN ULINE. We will have our Remote Function residing here. Set the Import and Export values. 3. 3. SELECTION-SCREEN SKIP num. Selection Screen Controls: 1. Save and activate the transaction. Page 15 of 16 . Function Modules: Steps involved are: 1. After competing the RF we have to release it.To Skip lines: Syntax. Go to se38 create open program and click the Pattern option in the menu to inherit the written function module.
We will have our Calling Program residing here.Client Side 1. In the Call Function we have to add Destination ‘< RFC Destination name>’. Page 16 of 16 . Execute the pgm. 2. 3.
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue listening from where you left off, or restart the preview.