Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Most urgent - LDBs

Former Member
0 Kudos

Hi,

Can you pleas egive me simple example to undersatnd the concept of Logical databases?(with simple coding example?)

Regards

Vijaya

3 REPLIES 3

raja_thangamani
Active Contributor
0 Kudos

Vijaya,

Check the following links: http://help.sap.com/saphelp_erp2005/helpdata/en/9f/db9b5e35c111d1829f0000e829fbfe/frameset.htm

 YOu can check the SAP program RFITEMGL.

Also check this custom code

REPORT SAMPLELDB.
 
TABLES: PROJ,
        PRPS_R,
        AUFK,
        ACT01,
        DRAD,
        DRAT,
        ELM_PS,
        RSTHIE,
        CNDB.
 
INCLUDE MZNW2D01.
 
INITIALIZATION.
  FREE MEMORY ID 'SAPDBPSJ999  AUFRUFE'.
 
GET RSTHIE.
  CLEAR ITAB_HIERARCHY.
  MOVE-CORRESPONDING RSTHIE TO ITAB_HIERARCHY.
 
GET PROJ FIELDS OBJNR PSPID POST1.
 
GET PRPS_R FIELDS OBJNR POSID POST1.
 
GET AUFK FIELDS OBJNR KTEXT.
 
GET ACT01 FIELDS OBJNR AUFPL APLZL VORNR UVORN LTXA1.
 
GET DRAD.
  MOVE-CORRESPONDING DRAD TO ITAB_DOCUMENTS.
  APPEND ITAB_DOCUMENTS.
 
GET ELM_PS.
  ITAB_HIERARCHY-OBJNR = ELM_PS-OBJNR.
  CASE ELM_PS-OBTYP.
    WHEN 'PD'.
      ITAB_HIERARCHY-PSPNR = ELM_PS-PROJ_INT.
      WRITE ELM_PS-PROJ_EXT TO ITAB_HIERARCHY-NAME.
    WHEN 'PR'.
      ITAB_HIERARCHY-PSPNR = ELM_PS-PRPS_INT.
      WRITE ELM_PS-PRPS_EXT TO ITAB_HIERARCHY-NAME.
    WHEN 'NP'.
      ITAB_HIERARCHY-AUFNR = ELM_PS-AUFNR.
      WRITE ELM_PS-AUFNR TO ITAB_HIERARCHY-NAME.
    WHEN 'NV'.
      ITAB_HIERARCHY-VORNR = ELM_PS-VORNR.
      WRITE ELM_PS-AUFNR TO ITAB_HIERARCHY-NAME.
      IF ACT01-UVORN IS INITIAL.
        CONCATENATE ITAB_HIERARCHY-NAME ACT01-VORNR
                    INTO ITAB_HIERARCHY-NAME SEPARATED BY ' / '.
      ELSE.
        CONCATENATE ITAB_HIERARCHY-NAME ACT01-VORNR ACT01-UVORN
                    INTO ITAB_HIERARCHY-NAME SEPARATED BY ' / '.
      ENDIF.
  ENDCASE.
  IF ELM_PS-KTEXT IS INITIAL.
     ITAB_HIERARCHY-DESC = ITAB_HIERARCHY-NAME.
   ELSE.
    ITAB_HIERARCHY-DESC = ELM_PS-KTEXT.
  ENDIF.
  ITAB_HIERARCHY-OBTYP = ELM_PS-OBTYP.
  APPEND ITAB_HIERARCHY.
  CLEAR ITAB_HIERARCHY.
 
END-OF-SELECTION.
  PERFORM READ_DRAT.
  PERFORM SAVE_PROJECT_HIERARCHY.
 
*---------------------------------------------------------------------*
*       FORM READ_DRAT                                                *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM READ_DRAT.
  DATA: C TYPE CURSOR.
  DATA: ITAB_DRAT LIKE DRAT.
 
  CHECK NOT ITAB_DOCUMENTS[] IS INITIAL.
  SORT ITAB_DOCUMENTS BY DOKAR DOKNR DOKVR DOKTL.
  OPEN CURSOR C FOR
    SELECT * FROM DRAT
           FOR ALL ENTRIES IN ITAB_DOCUMENTS
           WHERE DOKAR = ITAB_DOCUMENTS-DOKAR
             AND DOKNR = ITAB_DOCUMENTS-DOKNR
             AND DOKVR = ITAB_DOCUMENTS-DOKVR
             AND DOKTL = ITAB_DOCUMENTS-DOKTL
           ORDER BY PRIMARY KEY.
 
  DO.
    FETCH NEXT CURSOR C INTO CORRESPONDING FIELDS OF ITAB_DRAT.
    IF NOT SY-SUBRC IS INITIAL.
      CLOSE CURSOR C.
      EXIT.
    ENDIF.
    READ TABLE ITAB_DOCUMENTS WITH KEY DOKAR = ITAB_DRAT-DOKAR
                                       DOKNR = ITAB_DRAT-DOKNR
                                       DOKVR = ITAB_DRAT-DOKVR
                                       DOKTL = ITAB_DRAT-DOKTL
                              BINARY SEARCH.
    LOOP AT ITAB_DOCUMENTS FROM SY-TABIX.
      IF ITAB_DOCUMENTS-DOKAR <> ITAB_DRAT-DOKAR OR
         ITAB_DOCUMENTS-DOKNR <> ITAB_DRAT-DOKNR OR
         ITAB_DOCUMENTS-DOKVR <> ITAB_DRAT-DOKVR OR
         ITAB_DOCUMENTS-DOKTL <> ITAB_DRAT-DOKTL.
        EXIT.
      ENDIF.
      IF ITAB_DOCUMENTS-DKTXT IS INITIAL OR
         ITAB_DRAT-LANGU      =  SY-LANGU.
        ITAB_DOCUMENTS-DKTXT = ITAB_DRAT-DKTXT.
        ITAB_DOCUMENTS-LANGU = ITAB_DRAT-LANGU.
        MODIFY ITAB_DOCUMENTS.
      ENDIF.
    ENDLOOP.
  ENDDO.
  SORT ITAB_DOCUMENTS BY OBJKY DOKAR DOKNR DOKVR DOKTL.
ENDFORM.
 
 
*---------------------------------------------------------------------*
*       FORM SAVE_PROJECT_HIERARCHY                                   *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM SAVE_PROJECT_HIERARCHY.
  CALL FUNCTION 'ENQUEUE_EC_CNDB'
       EXPORTING
            RELID          = '00'
            SRTFD          = 'SAP         DIRECTORY'
            _WAIT          = 'X'
       EXCEPTIONS
            FOREIGN_LOCK   = 1
            SYSTEM_FAILURE = 2
            OTHERS         = 3.
  IF NOT SY-SUBRC IS INITIAL.
    IF SY-SUBRC = 1.
      MESSAGE I501 WITH SY-MSGV1 RAISING DIR_ENTRY_NOT_SAVED.
    ENDIF.
    EXIT.
  ENDIF.
  IMPORT CNDBDIR TO ITAB_CNDBDIR
         FROM DATABASE CNDB(00) ID 'SAP         DIRECTORY'.
  READ TABLE ITAB_HIERARCHY INDEX 1.
  CLEAR CNDBDIR_TMP.
  CNDBDIR_TMP-RELID    = 'W2'.
  CNDBDIR_TMP-SRTFD    = ITAB_HIERARCHY-OBJNR.
  CNDBDIR_TMP-DBPROG   = 'SAPDBPSJ'.
  CNDBDIR_TMP-REPORT   = SY-CPROG.
  CNDBDIR_TMP-DATUM    = SY-DATUM.
  CNDBDIR_TMP-DATLO    = SY-DATLO.
  CNDBDIR_TMP-TIMLO    = SY-TIMLO.
  SORT ITAB_CNDBDIR BY RELID SRTFD.
  READ TABLE ITAB_CNDBDIR WITH KEY RELID = 'W2'
                                   SRTFD = ITAB_HIERARCHY-OBJNR
                                   BINARY SEARCH.
  IF SY-SUBRC IS INITIAL.
    DELETE ITAB_CNDBDIR INDEX SY-TABIX.
  ENDIF.
  ITAB_CNDBDIR = CNDBDIR_TMP.
  INSERT ITAB_CNDBDIR INDEX SY-TABIX.
  EXPORT CNDBDIR FROM ITAB_CNDBDIR
         TO DATABASE CNDB(00) ID 'SAP         DIRECTORY'.
 
  CALL FUNCTION 'DEQUEUE_EC_CNDB'
       EXPORTING
            RELID = '00'
            SRTFD = 'SAP         DIRECTORY'.
 
  EXPORT ITAB_HIERARCHY TO DATABASE CNDB(W2) ID ITAB_CNDBDIR-SRTFD.
  EXPORT ITAB_DOCUMENTS TO DATABASE CNDB(W3) ID ITAB_CNDBDIR-SRTFD.
ENDFORM.

0 Kudos

here're some dem-progs.:

DEMO_PROGRAM_CALL_TRANSACTION

DEMO_PROGRAM_CHECK_1

DEMO_PROGRAM_CHECK_2

DEMO_PROGRAM_END_OF_SELECTION

DEMO_PROGRAM_EXIT_1

DEMO_PROGRAM_EXIT_2

DEMO_PROGRAM_GET

DEMO_PROGRAM_GET_LATE

DEMO_PROGRAM_INITIALIZATION

DEMO_PROGRAM_READ_TABLES_2

DEMO_PROGRAM_REJECT

DEMO_PROGRAM_START_OF_SELECTIO

DEMO_PROGRAM_STOP

DEMO_SELECTION_SCREEN_LDB_1

DEMO_SELECTION_SCREEN_LDB_2

DEMO_SELTAB_GET_EVENT

DEMO_SEL_SCREEN_SELECT_LDB_1

DEMO_SEL_SCREEN_SELECT_LDB_2

DEMO_SEL_SCREEN_STANDARD_SEL_S