Showing posts with label #stringoperations. Show all posts
Showing posts with label #stringoperations. Show all posts

Monday, 30 May 2016

Logical Databases and usage

Logical Databases and usage

  • Database within a database, but logically stored within existing (physical) tables.

  • Logical databases are special ABAP programs that retrieve data and make it available to application programs. The most common use of logical databases is still to read data from database tables by linking them to executable ABAP programs.
  • Logical databases contain Open SQL statements that read data from the database. You do not therefore need to use SQL in your own programs. The logical database reads the program, stores them in the program if necessary, and then passes them line by line to the application program or the function module LDB_PROCESS using an interface work area.

function module ( SE 37 ) : LDB_PROCESS



Logical Databases -Views of Data


  • A logical database provides a particular view of database tables in the R/3 System. It is always worth using logical databases if the structure of the data that you want to read corresponds to a view available through a logical database.
  • The data structure in a logical database is hierarchical. Many tables in the R/3 System are linked to each other using foreign key relationships. Some of these dependencies form tree-like hierarchical structures. Logical databases read data from database tables that are part of these structures.


  • The diagram illustrates how the R/3 System might represent the structure of a company. A logical database can read the lines of these tables one after the other into an executable program in a sequence which is normally defined by the hierarchical structure. The term logical database is sometimes used to mean not only the program itself, but also the data that it can procure.

Tasks of Logical Databases


  1. Reading the same data for several programs.
  2. Defining the same user interface for several programs.
  3. Central authorization checks.
  4. Improving performance

Structure of a Logical Database



Reading Data




Event Key Words: Overview


Interaction of Logical Databases and Report





Ex :
Report (SE 38)-Driven Reading of Vendor Master Data




The STOP Statement




Logical Database vs. Select





----------------------

Friday, 27 May 2016

Condense --[NO-GAPS]

Syntax


CONDENSE text [NO-GAPS].
  • In the variable text, leading and closing blanks are completely removed and any other directly consecutive blanks are all replaced by exactly one space character or - if NO-GAPS is specified - are also removed completely.
  • The data object text must be character-type. If the data object has a fixed length, any space created by the condense operation is filled with blanks on the right. If the data object is of the type string, its length is adapted to the result of the condense operation.


Source code


PARAMETERS TXT TYPE STRING.

CONDENSE txt NO-GAPS   .

WRITE TXT.


Input


Output



Usage of Concatenate and offset (string operations ) in date formate

Ex :


DATA DT(10TYPE C.
PARAMETERS DATE TYPE D.

CONCATENATE DATE+6(2':' DATE+4(2':' DATE(4INTO DT.

WRITE / DT.




Source Code


Input





Output








Splitting string based on position->using offset concept



Source Code


DATA TXT2 TYPE STRING.
PARAMETERS TXT TYPE STRING.

TXT1 TXT(3).
TXT2 TXT+3(4).

WRITE / TXT1 /  TXT2 .


Input




Output






                            For more information........

Translate

Translate

  • Statement converts the case or single characters of the character-type data object text. The statement CASE can be used for the conversion to upper/lower case; USING can be used for the conversion according to a mask. The variable text must be character-type. 
  • Syntax :
TRANSLATE text {TO {UPPER|LOWER} CASE}
             | {USING mask}.


Ex : 
  1. ... USING  mask.

Source Code :


PARAMETERS txt TYPE string.


TRANSLATE txt USING 'AB' .


WRITE txt.




Input



Output


  • This is works similar to replace all occurrences of .
--------------------------------------------------------------------------------------
Ex 2.

  • TO LOWER CASE or  TO UPPER CASE.


Source Code


PARAMETERS txt TYPE string.


TRANSLATE txt TO LOWER CASE.


WRITE txt.



Input




Output





                               For more information.......


Replace all occurrences of

Replace all occurrences of

  • Used to replace all the occurrences  in the given string.

Ex :

Source Code


PARAMETERS txt TYPE string.


REPLACE all OCCURRENCES OF  'A' IN  txt WITH 'B'.


WRITE txt.





Input




Output



---------------------------------------------------------------------------------

Replace

Replace


  • Replace command replace only 1st occurrence in String.

Ex :

Source Code


PARAMETERS txt TYPE string.


REPLACE 'A' WITH 'B' INTO txt.


WRITE txt.



Input


Output





Split



Syntax

       SPLIT dobj AT sep INTO
      { {result1 result2 ...} | {TABLE result_tab} }
      [IN {CHARACTER|BYTE} MODE].



Ex :


Source Code


data txt2 TYPE string,
       txt3 TYPE string.

PARAMETERS txt TYPE string.


SPLIT txt AT space INTO txt2 txt3.


WRITE txt2/ txt3.








Input



Output








Alignments




  1. RIGHT-JUSTIFIED
  2. CENTERED
  3. LEFT-JUSTIFIED

  • By default always characters are left justified and numbers are right justified.

Ex : Without Alignment.


Source Code




PARAMETERS num TYPE i,
             name(10TYPE c.

WRITE num / name .



Save ->check -> Activate.

Input




Output



----------------------------------------------------



Ex : 2 . With alignment.


Source Code :



PARAMETERS num TYPE i,
             name(10TYPE c.

WRITE num LEFT-JUSTIFIED / name  RIGHT-JUSTIFIED.





Input




Output




--------------------------------------------------------------------------------------------





Wednesday, 25 May 2016

Concatenate

Concatenate: Used to combine the characters or Strings.

Ex 1: Concatenating string without space.

Source Code:


 DATA : txt3 TYPE string.

PARAMETERS : txt1 TYPE string,

             txt2 TYPE string .



CONCATENATE  txt1  txt2 INTO txt3.

WRITE : / txt3.







Input :





Output :




------------------------------------------------------------------------------------------

Ex 2 : Concatenating string with space using Separated by space keyword.

Source Code:

data : txt3 TYPE string.

PARAMETERS : txt1 TYPE string,

             txt2 TYPE string .



CONCATENATE  txt1  txt2 INTO txt3 separated by space.

WRITE : / txt3 .





Input 


Output