Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 3523

Abap Query Call function

$
0
0

Hi Experts,

 

I want to ask how to link Sales text of material master in ABAP Query, I already have "Read_Text" call function for script.

Please guide me from where i have to pick ABAP code of call function and how to update it in info set of query.

 

 

Given is my whole call function abap code. kindly teach me step by step process update call function.

 

 

************************************************

 

FUNCTION READ_TEXT.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     VALUE(CLIENT) LIKE  SY-MANDT DEFAULT SY-MANDT
*"     VALUE(ID) LIKE  THEAD-TDID
*"     VALUE(LANGUAGE) LIKE  THEAD-TDSPRAS
*"     VALUE(NAME) LIKE  THEAD-TDNAME
*"     VALUE(OBJECT) LIKE  THEAD-TDOBJECT
*"     VALUE(ARCHIVE_HANDLE) LIKE  SY-TABIX DEFAULT 0
*"     VALUE(LOCAL_CAT) DEFAULT SPACE
*"  EXPORTING
*"     VALUE(HEADER) LIKE  THEAD STRUCTURE  THEAD
*"     VALUE(OLD_LINE_COUNTER) TYPE  THEAD-TDTXTLINES
*"  TABLES
*"      LINES STRUCTURE  TLINE
*"  EXCEPTIONS
*"      ID
*"      LANGUAGE
*"      NAME
*"      NOT_FOUND
*"      OBJECT
*"      REFERENCE_CHECK
*"      WRONG_ACCESS_TO_ARCHIVE
*"----------------------------------------------------------------------
" B20K074874 ... READ_TEXT resolves references in CATALOG
"                with READ_REFERENCE_LINES
"                resolve references for texts created with COPY_TEXTS
" B20K024363 ... Replace SY-TFILL with DESCRIBE
" B20K023213 ... Optimizing Performance with referenced texts
" B20K019187 ... New module COPY_TEXTS
" B20K019113 ... Process non-SAPscript texts
*-----------------------------------------------------------------------
DATA THEADER LIKE THEAD.
DATA STXH_WA LIKE STXH.
DATA NEWTEXT LIKE BOOLEAN.
DATA L_LANGUAGE(2).                         " for two char language code


*...Prüfen ob vom Archiv gelesen werden soll............................
IF ARCHIVE_HANDLE > 0.
   CALL FUNCTION   'TEXT_READ_ARCHIVE_OBJECT'
          EXPORTING  ARCHIVE_HANDLE          = ARCHIVE_HANDLE
                     ID                      = ID
                     LANGUAGE                = LANGUAGE
                     NAME                    = NAME
                     OBJECT                  = OBJECT
                     CLIENT                  = CLIENT
          IMPORTING  HEADER                  = HEADER
          TABLES     LINES                   = LINES
          EXCEPTIONS NOT_FOUND               = 1
                     WRONG_ACCESS_TO_ARCHIVE = 2.
   CASE SY-SUBRC.
   WHEN 1. MESSAGE E600 WITH NAME ID LANGUAGE RAISING NOT_FOUND.
   WHEN 2. MESSAGE A020 RAISING WRONG_ACCESS_TO_ARCHIVE.
   ENDCASE.
   EXIT.
ENDIF.

*...Initialisierung.....................................................
NEWTEXT   = FALSE.
REFERENCE = FALSE.

*...Pruefen Aufrufparameter.............................................
PERFORM CHECK_KEY USING OBJECT NAME ID LANGUAGE.
perform check_catalog_local using local_cat.
*...Text aus Textmemory lesen...........................................
IF TTXOB-TDSAVEMODE = SAVEMODE_POSTING.
   PERFORM IMPORT_CATALOG.
   if client = sy-mandt.
   PERFORM READ_CATALOG USING OBJECT NAME ID LANGUAGE.
   IF SY-SUBRC = 0.
     CASE CATALOG-FUNCTION.
*     text will be deleted
       WHEN FUNCTION_DELETE.
         REFRESH LINES. CLEAR LINES.
         CALL FUNCTION  'SAPSCRIPT_MESSAGE_DEF'
                  EXPORTING NO = 600
                            V1 = NAME
                            V2 = ID
                            V3 = LANGUAGE.
         MESSAGE E600 WITH NAME ID LANGUAGE RAISING NOT_FOUND.
*     text will be created new
       WHEN FUNCTION_INSERT.
         CLEAR THEADER. REFRESH LINES.                        "B20K074874
         IMPORT THEAD TO THEADER                              "
                TLINE TO LINES                                "
           FROM MEMORY ID MEMORY_ID.                          "
         HEADER        = THEADER.                             "
         HEADER-TDNAME = CATALOG-TDNAME.                      "
         PERFORM READ_REFERENCE_LINES TABLES LINES            "
                                      USING CLIENT            "
                                            HEADER.           "
         DESCRIBE TABLE LINES LINES HEADER-TDTXTLINES.        "
*     text will be updated
       WHEN FUNCTION_UPDATE.
         CLEAR THEADER. REFRESH LINES.                        "B20K074874
         IMPORT THEAD TO THEADER                              "
                TLINE TO LINES                                "
           FROM MEMORY ID MEMORY_ID.                          "
         HEADER = THEADER.                                    "
         PERFORM READ_REFERENCE_LINES TABLES LINES            "
                                      USING CLIENT            "
                                            HEADER.           "
         DESCRIBE TABLE LINES LINES HEADER-TDTXTLINES.        "
*     text will be copied from other DB text at COMMIT_TEXT
       WHEN FUNCTION_COPY.
         PERFORM IMPORT_COPY_CATALOG.
         READ TABLE COPY_CATALOG INDEX CATALOG-COPYINDEX.
         IF SY-SUBRC = 0.
           HEADER-TDOBJECT  = CATALOG-TDOBJECT.
           HEADER-TDNAME    = CATALOG-TDNAME.
           HEADER-TDID      = CATALOG-TDID.
           HEADER-TDSPRAS   = CATALOG-TDSPRAS.
           THEADER-TDOBJECT = COPY_CATALOG-TDOBJECT.
           THEADER-TDNAME   = COPY_CATALOG-TDNAME.
           THEADER-TDID     = COPY_CATALOG-TDID.
           THEADER-TDSPRAS  = COPY_CATALOG-TDSPRAS.
           PERFORM BUILD_COPY_HEADER USING HEADER
                                           THEADER
                                           FUNCTION_COPY.
           IF THEADER-TDREFOBJ = SPACE AND                    "B20K074874
              THEADER-TDREFID  = SPACE AND                    "
              THEADER-TDREFNAME = SPACE.                      "
             PERFORM READ_TEXTLINES TABLES LINES              "
                                    USING  THEADER            "
                                           SY-MANDT.          "
           ELSE.                                              "
             PERFORM READ_REFTEXT_LINES TABLES LINES          "
                                        USING  THEADER        "
                                               SY-MANDT.      "
           ENDIF.
           header-tdtxtlines = theader-tdtxtlines.
         ENDIF.
*     text will be updated from other DB text at COMMIT_TEXT
       WHEN FUNCTION_COPYUPDATE.
         PERFORM IMPORT_COPY_CATALOG.
         READ TABLE COPY_CATALOG INDEX CATALOG-COPYINDEX.
         IF SY-SUBRC = 0.
           SELECT SINGLE * FROM STXH INTO STXH_WA
             WHERE TDOBJECT = CATALOG-TDOBJECT
               AND TDNAME   = CATALOG-TDNAME
               AND TDID     = CATALOG-TDID
               AND TDSPRAS  = CATALOG-TDSPRAS.
           CHECK SY-SUBRC = 0.
           MOVE-CORRESPONDING STXH_WA TO HEADER.
           THEADER-TDOBJECT = COPY_CATALOG-TDOBJECT.
           THEADER-TDNAME   = COPY_CATALOG-TDNAME.
           THEADER-TDID     = COPY_CATALOG-TDID.
           THEADER-TDSPRAS  = COPY_CATALOG-TDSPRAS.
           PERFORM BUILD_COPY_HEADER USING HEADER
                                           THEADER
                                           FUNCTION_COPYUPDATE.
           IF THEADER-TDREFOBJ = SPACE AND                    "B20K074874
              THEADER-TDREFID  = SPACE AND                    "
              THEADER-TDREFNAME = SPACE.                      "
             PERFORM READ_TEXTLINES TABLES LINES              "
                                    USING  THEADER            "
                                           SY-MANDT.          "
           ELSE.                                              "
             PERFORM READ_REFTEXT_LINES TABLES LINES          "
                                        USING  THEADER        "
                                               SY-MANDT.      "
           ENDIF.
           header-tdtxtlines = theader-tdtxtlines.
         ENDIF.
*     no action is performed since text was created and deleted
       WHEN FUNCTION_NONE.
         REFRESH LINES. CLEAR LINES.
         CALL FUNCTION  'SAPSCRIPT_MESSAGE_DEF'
                  EXPORTING NO = 600
                            V1 = NAME
                            V2 = ID
                            V3 = LANGUAGE.
         MESSAGE E600 WITH NAME ID LANGUAGE RAISING NOT_FOUND.
     ENDCASE.
   ELSE.
     NEWTEXT = TRUE.
   ENDIF.
   else.
      newtext = true.
   endif.
ENDIF.

*...Text aus Textdatei lesen............................................
IF TTXOB-TDSAVEMODE = SAVEMODE_DIALOG OR NEWTEXT = TRUE.
   SELECT SINGLE * FROM STXH CLIENT SPECIFIED
      WHERE MANDT    = CLIENT
        AND TDOBJECT = OBJECT
        AND TDNAME   = NAME
        AND TDID     = ID
        AND TDSPRAS  = LANGUAGE.
   IF SY-SUBRC > 0.
     WRITE LANGUAGE TO L_LANGUAGE(2).
     CALL FUNCTION  'SAPSCRIPT_MESSAGE_DEF'
             EXPORTING NO = 600
                       V1 = NAME
                       V2 = ID
                       V3 = L_LANGUAGE.
     MESSAGE E600 WITH NAME ID LANGUAGE RAISING NOT_FOUND.
   ELSE.
     MOVE-CORRESPONDING STXH TO HEADER.
     OLD_LINE_COUNTER = HEADER-TDTXTLINES.
     IF STXH-TDREF = TRUE.
       PERFORM READ_REFTEXT_LINES TABLES LINES
                                   USING  HEADER
                                          CLIENT.
     ELSE.
       PERFORM READ_TEXTLINES TABLES LINES
                               USING  HEADER
                                      CLIENT.
       IF SY-SUBRC > 0.
         REFRESH LINES. CLEAR LINES.
       ENDIF.
     ENDIF.
   ENDIF.
ENDIF.

*...Ausgabeparameter setzen.............................................
if header-tdtexttype is initial.   " just for ITF
   HEADER-TDLINESIZE = TTXOB-TDLINESIZE.
endif.

ENDFUNCTION.

* read LINES of a reference text found in CATALOG            "B20K074874
* returns SY-SUBRC = 0 if found
FORM READ_REFERENCE_LINES TABLES LINES STRUCTURE TLINE
                           USING CLIENT
                                 VALUE(HEADER) LIKE THEAD.
STATICS: TEXT_IN_CATALOG LIKE BOOLEAN.

TEXT_IN_CATALOG = TRUE.
PERFORM CHECK_REFERENCE USING HEADER-TDREFOBJ            "sets REFERENCE
                               HEADER-TDREFNAME
                               HEADER-TDREFID.
IF REFERENCE = FALSE.
   EXIT.
ENDIF.
* resolve reference chain in CATALOG
WHILE REFERENCE = TRUE AND TEXT_IN_CATALOG = TRUE.
   PERFORM READ_CATALOG USING HEADER-TDREFOBJ
                              HEADER-TDREFNAME
                              HEADER-TDREFID
                              HEADER-TDSPRAS.
   IF SY-SUBRC = 0.
*   read header from MEMORY
     CASE CATALOG-FUNCTION.
*     text will be deleted
       WHEN FUNCTION_DELETE.
         MESSAGE E610 WITH CATALOG-TDOBJECT
                           CATALOG-TDID
                           CATALOG-TDNAME
                           CATALOG-TDSPRAS
           RAISING REFERENCE_CHECK.
*     text will be created new
       WHEN FUNCTION_INSERT.
         IMPORT THEAD TO HEADER
                TLINE TO LINES
           FROM MEMORY ID MEMORY_ID.
         PERFORM CHECK_REFERENCE USING HEADER-TDREFOBJ   "sets REFERENCE
                                       HEADER-TDREFNAME
                                       HEADER-TDREFID.
*     text will be updated
       WHEN FUNCTION_UPDATE.
         IMPORT THEAD TO HEADER
                TLINE TO LINES
           FROM MEMORY ID MEMORY_ID.
         PERFORM CHECK_REFERENCE USING HEADER-TDREFOBJ   "sets REFERENCE
                                       HEADER-TDREFNAME
                                       HEADER-TDREFID.
*     text will be copied from DB text at COMMIT_TEXT
       WHEN FUNCTION_COPY.          "COPY_TEXTS copies from DB
         TEXT_IN_CATALOG = FALSE.
       WHEN FUNCTION_COPYUPDATE.    "COPY_TEXTS copies from DB
         TEXT_IN_CATALOG = FALSE.
       WHEN FUNCTION_NONE.          "read from DB
         TEXT_IN_CATALOG = FALSE.
     ENDCASE.
   ELSE.
     TEXT_IN_CATALOG = FALSE.
   ENDIF.
ENDWHILE.
IF REFERENCE = TRUE.
   REFRESH LINES.
* read text from DB?
   IF TEXT_IN_CATALOG = FALSE.
     PERFORM READ_REFTEXT_LINES TABLES LINES
                                USING  HEADER
                                       CLIENT.
*
   ENDIF.
ELSE.
* LINES have been filled by IMPORT ....
ENDIF.
ENDFORM.

***************************************************************************************************************

 

Regards,

Qamber Abbas


Viewing all articles
Browse latest Browse all 3523

Trending Articles