Open SQL syntax examples

Working with single entries select * from ska1where saknr = ‘77004500’.* Do something with datamove-corresponding ska1 to itab.append itab. endselect. Reading all entries into an internal table This is more efficient that example 1 select * from ska1 into table itabwhere saknr like ‘77%’order by saknr. Reading single entries You must specify the full primarykey … Read more

Updating database tables – SQL Query

Updating records in the database table from an internal table table: personel.data: itab like personel. * Read records from the database table where name is space, into an internal tableselect * from personal into table itabwhere name = space. * Update name in the internal table to Unknownloop at itab.itab-name = ‘Unknown’endloop. * Modify records … Read more

How to Use Dynamic SQL in ABAP report

Dynamic where clause You can use an internal table to build a dynamic where clause: data: where_tab(30) occurs 1 with header line, where_clause(30) type c. * Build the where clause. Will look like this when finished* WHERE ZAFSTMD02 = ‘X’ AND rbusa = ‘5145’ * With a constant, result: ZAFSTMD01 = ‘X’concatenate ‘ZAFSTMD’ zcostcheck-zmaaned ‘ … Read more

Assign Variable Type at Runtime in ABAP report

Dynamic programing can save a lot of ‘superfluous’ coding. To assign a variable a type at runtime, use the ABAP statement ASSIGN with the option TYPE. For instance: DATA: D_TYPE,D_FIELD(35).DATA: D_TEST TYPE P.FIELD-SYMBOLS: .D_FIELD = ‘D_TEST’.D_TYPE = ‘P’.ASSIGN (D_FIELD) TO TYPE D_TYPE. Additionally you can use the option DECIMALS of the ASSIGN statement if your … Read more

Report to Find User-Exit for Transaction Code

Copied from From SapGenie.com http://www.sapgenie.com/abap/code/abap26.htm Selection Text: P_TCODE: Transaction Code to Search Text Symbols: 001 – Enter the Transaction Code that you want to search through for a User Exit REPORT z_find_userexit NO STANDARD PAGE HEADING. *&———————————————————————* *& Enter the transaction code that you want to search through in order *& to find which Standard … Read more

Reading and writing to a flatfile

Reading and writing to a flatfile Use transaction AL11 to view the files on the apllication server. (1)Writing to a flatfile(2)Reading a file(3)Authority check Writing to a flatfile Note: If the path is not inlcuded in the file name, the file isqwritten to the default directory on the apllication server (The systemuses the directory defined … Read more

Validation of selection screens

Validation of selection screen can be performed in the AT SELECTION SCREEN event. Example: ************************************************************************* AT SELECTION SCREEN *************************************************************************at selection-screen. perform validate_selection_screen using g_returkode. if g_returkode = c_returkode_error. exit. endif. *&———————————————————————**& Form validate_selection_screen*&———————————————————————** Validation of selection screen*———————————————————————-** –>P_G_RETURKODE text*———————————————————————-*form validate_selection_screen using p_returkode. if s_framd > 12 or s_framd < 1 or s_tilmd > 12 or … Read more

Submitting another report using select-options or ranges

Example 1: Submitting a report using ranges for select-options * Define range for ltak-tanumRANGES: r_tanum FOR ltak-tanum. * Read values from database tabel into the range* These values are later used for select-options in the report SELECT * FROM ltak WHERE lgnum = w_lgnum AND “Warehouse number/complex vbeln = w_screen1000-io_vbeln. “Transfer order number MOVE ltak-tanum … Read more