Internal table & Work area

Hi Experts,
I am a novice to ABAP. Can anyone tell me whats the difference b/w internal table and work area. In writing function modules how these will be utilized and in what way.
Regards
ss

HI,
Internal tables are a standard data type object which exists only during the runtime of the program. They are used to perform table calculations on subsets of database tables and for re-organising the contents of database tables according to users need.
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb35de358411d1829f0000e829fbfe/content.htm
Difference between Work Area and Header Line
While adding or retrieving records to / from internal table we have to keep the record temporarily.
The area where this record is kept is called as work area for the internal table.  The area must have the same structure as that of internal table. An internal table consists of a body and an optional header line.
Header line is a implicit work area for the internal table.  It depends on how the internal table is declared that the itab will have the header line or not.
e.g.
data: begin of itab occurs 10,
           ab type c,
           cd type i,
        end of itab.  " this table will have the header line.
data: wa_itab like itab. " explicit work area for itab
data: itab1 like itab occurs 10. " table is without header line.
The header line is a field string with the same structure as a row of the body, but it can only hold a single row.
It is a buffer used to hold each record before it is added or each record as it is retrieved from the internal table.  It is the default work area for the internal table
1) The difference between
whih header line and with out heater line of internal table.
ex:-
a) Data : itab like mara occurs 0 with header line.
b) Data: itab like mara occurs 0.
-While adding or retrieving records to / from internal table we have to keep the record temporarily.
-The area where this record is kept is called as work area for the internal table.
-The area must have the same structure as that of internal table. An internal table consists of a body and an optional header line.
-Header line is a implicit work area for the internal table. It depends on how the internal table is declared that the itab will have the header line or not.
a) Data : itab like mara occurs 0 with header line.
table is with header line
b) Data: itab like mara occurs 0.
table is without header line
2)work area / field string and internal table
which one is prefarable for good performance any why ?
-The header line is a field string with the same structure as a row of the body, but it can only hold a single row , whereas internal table can have more than one record.
In short u can define a workarea of an internal table which means that area must have the same structure as that of internal table and can have one record only.
Example code:
data: begin of itab occurs 10,
ab type c,
cd type i,
end of itab. " this table will have the header line.
data: wa_itab like itab. " explicit work area for itab
data: itab1 like itab occurs 10. " table is without header line.
http://www.allsaplinks.com/faq_abap_internaltables.html
Do reward if it helps,
Regards,
Laxmi

Similar Messages

  • I am getting problem with internal table & work area declaration.

    I am working with 'makt' table ..with the table makt i need to work with styles attributes ..so i declared like this
    TYPES : BEGIN OF ty_makt,
             matnr TYPE makt-matnr,
             spras TYPE makt-spras,
             maktx TYPE makt-maktx,
             maktg TYPE makt-maktg,
             celltab TYPE lvc_t_styl,
           END OF ty_makt.
    DATA : i_makt TYPE TABLE OF ty_makt.
    DATA : wa_makt TYPE ty_makt .
        But end of program i need to update dbtable "makt"...i am getting problem with internal table & work area declaration.
    i think makt table fields mapping and internal table/work area mapping is not correct. so please help me to get out from this.

    Hi Nagasankar,
    TYPES : BEGIN OF TY_MATNR,
                  MATNR TYPE MAKT-MATNR,
                  SPRAS TYPE MAKT-SPRAS,
                  MAKTX TYPE MAKT-MAKTX,
                  MAKTX TYPE MAKT-MAKTG,
                  CELLTAB TYPE LVC_T_STYL,  " Its Working perfectly fine..
                 END OF TY_MAKT.
    DATA: IT_MAKT TYPE STANDARD TABLE OF TY_MAKT,
              WA_MAKT TYPE TY_MAKT.
    Its working perfectly fine. if still you are facing any issue post your complete code.
    Thanks,
    Sandeep

  • Internal Table - Work Area issue

    Guru's:
    I am selecting the mentioned fields from TVAKT into t_itt1 (internal table) - I however an encountering "you canot use an internal table as a work area" as an error.
    DATA: s_bezei LIKE tvakt-bezei,
          s_auart LIKE tvakt-auart.
    DATA t_itt1 LIKE tvakt OCCURS 0.
    DATA z_itt LIKE tvakt.
    its at this stage of the code that I am facing this problem
    SELECT spras auart bezei FROM tvakt
    INTO t_itt1
    WHERE bezei IN s_bezei
    AND auart IN s_auart.
    would appreciate your help.

    Hello,
    You need to change the declaration of the s_spras to use the IN clause:
    See these for more informations: http://help.sap.com/saphelp_nw04/helpdata/en/18/a1f251e28b11d295f500a0c929b3c3/frameset.htm and Create a Ranges Table Type.
    Regards.

  • Internal table - work area not long enough

    Subject changed by moderator.  Please try to use a more meaningful subject in future
    The work area "ITAB" is not long enough. how to solve this problem.
    Edited by: Matt on Nov 14, 2008 10:20 AM

    please check the order of the fields you are passing to your internal table.
    Their can be many  possible cases .
    a)
    internal table has less number of fields and u are passing more fields.
    b)
    suppose Itab has field Vbeln and it`s length is 10 and u are passing filed having length
    12.
    Please check that.
    Regards
    Neha

  • Moving internal table work area data to string

    Hi, I am running a program  with unicode enable.I am moving data from work area to string where i am getting a error like String & work area are not mutually convertable in Uni code program.
    Can any one help me how to resolve this problem.
    Thanks & Regards,
    Pratap.

    Hi Pratap kumar,
    sorry, need to do some redesign:
    You could poiibly concatenate the components of the structure into a string - if they are all character-like. And you will loose leading and trailing spaces.
    Non-character-componets must be converted (WRITE TO) into character-like fields.
    If you need the exact position in your string, you have to place all values at calculatzed offset in a (big enough) character field like CHAR1024.
    Altogether it might be easier to re-think and re-build according to results required. As you did not mention where you have this question, I have no special idea on how to solve.
    Regards,
    Clemens

  • Regarding tables work area,events in reporting,LSMW

    Hai to All,
    1. Sequence of events in classical & interactive reporting.
    2. Why call transaction does not support LSMW
                                  (Legasy System Migration Workbench)
    3. We have to provide tables work area in the declaration when select-options logic is used but it is not mandatory in parameters selection screen logic why?
    4. what is the reason for maintaining <b>loop ... endloop</b> logic under PAI in the case of  table control
    please provide answers for these quections
    regards,
    suryanarayana k.

    Hi
    1. Sequence of events in classical & interactive reporting.
    Events in ABAP Programming
    Classical Reporting:
    INITIALIZATION
    AT SELECTION-SCREEN OUTPUT
    AT SELECTION-SCREEN
    START-OF–SELECTION.
    TOP-OF-PAGE
    END-OF-PAGE
    END-OF-SELECTION.
    Events in Interactive Report
    TOP-OF-PAGE DURING LINE-SELECTION
    AT USER-COMMAND.
    AT LINE-SELECTION
    AT PF-FUNCTION KEY
    2. Why call transaction does not support LSMW
    (Legasy System Migration Workbench)
    http://www.sapbrain.com/TOOLS/LSMW/SAP_LSMW_steps_introduction.html
    http://esnips.com/doc/8e732760-5548-44cc-a0bb-5982c9424f17/lsmw_sp.ppt
    http://esnips.com/doc/f55fef40-fb82-4e89-9000-88316699c323/Data-Transfer-Using-LSMW.zip
    http://esnips.com/doc/1cd73c19-4263-42a4-9d6f-ac5487b0ebcb/LSMW-with-Idocs.ppt
    http://esnips.com/doc/ef04c89f-f3a2-473c-beee-6db5bb3dbb0e/LSMW-with-BAPI.ppt
    http://esnips.com/doc/7582d072-6663-4388-803b-4b2b94d7f85e/LSMW.pdf
    for Long texts Upload
    Please take a look at this..
    http://help.sap.com/saphelp_erp2005/helpdata/en/e1/c6d30210e6cf4eac7b054a73f8fb1d/frameset.htm
    3. We have to provide tables work area in the declaration when select-options logic is used but it is not mandatory in parameters selection screen logic why?
    When youd eclarae select-options by default it creates a selection table with 4 fields called SIGN,OPTIOn,LOW and HIGH fields
    Paramters its' not like that
    4. what is the reason for maintaining loop ... endloop logic under PAI in the case of table control
    Table control means handling multiple records , so to process/handle them it is a must to use loop.endloop.
    Reward points for useful Answers
    Regards
    Anji

  • Time out error 1.6 million internal table fields are computed using FMs

    Hi , All ...
    The Report running fine in server with less 300 record but ...production server which has 1.6 million record it  gives error as time-out error and takes hell amount of time.
    Please suggest ugently ..
    I have tried few things
    Internal table having 1.6 lacs ... fields to compute .. i have token in a batch
    loop at i_cinfo into s_cinfo from 1 to  100000.
    and so on ...also applied all the performace related .. like indexs, work areas , deleting adjacent duplicates , for all entries ..wherever applicable.
    Please Suggest .
    Report is as below
    REPORT  ZUSOTCBD_CREDIT_REPORT .
    TABLES : KNA1,    " General Data Customer Master
             KNB1,    " Customer Master (Company Code)
             KNC1,    " Customer master (transaction figures)
             KNKK,    " Customer master credit management: Control area data
             T009,    " Fiscal Year Variants P
             T009Y,   " Shortened fiscal years in Asset Accounting P
             T001,    " Co. Codes
             T001CM,  " Permitted Credit Control Areas per Company Code
             RF42B,   " Structure to hold credit data.
             RF035,   " Structure to hold credit managment fields
             RF02L,   " Structure to hold credit data.
             TRAS,    " Interval for Days in Arrears P
             T000CM.  " Data for DSO calculation.
    Types
    TYPES:
      BEGIN OF type_final,
        string(50) TYPE c,                            " String Value for Title
      END OF type_final.
    data:wa_final     TYPE type_final.                " Work Area to hold Title Data
    DATA:    RASID    TYPE RF035-RASID value 'R03N'. " For Days in interval
    DATA:    MONAT(2) TYPE N.
    DATA:    GJAHR    TYPE  KNC1-GJAHR.
    DATA:    LD_PERIODS(32) TYPE N
                           VALUE '01020304050607080910111213141516'.
    DATA     sytabix type sy-tabix.
    DATA     LAND      TYPE KNA1-LAND1 VALUE 'US'.   " Country Key
    DATA:   LD_PERIOD    TYPE BSID-MONAT,            " Fiscal Year Variant
            LD_GJAHR   TYPE KNC1-GJAHR,
            LD_COUNTER TYPE SY-TABIX.
    Internal Tables
    Internal table to hold Title Data                                   *
    DATA:
      i_final    TYPE STANDARD TABLE OF type_final.
    **Internal Table Permitted Credit Control Areas per Company Code
    DATA:    BEGIN OF TCMTAB OCCURS 10.
            INCLUDE STRUCTURE T001CM.
    DATA:    END   OF TCMTAB.
    *Internal table to store Customer no.
    DATA :  BEGIN OF ICUST OCCURS 0,
               KUNNR             TYPE KNA1-KUNNR,    " Customer No.
            END   OF ICUST.
    DATA:    BEGIN OF BUKTAB OCCURS 20,
               KKBER             LIKE T001-KKBER,    " Credit Control Area
               BUKRS             LIKE T001-BUKRS,    " Co. Code
               WAERS             LIKE T001-WAERS,    " Currency
               PERIV             LIKE T001-PERIV,    " Fiscal Year Variant
               BUTXT             LIKE T001-BUTXT,
             END   OF BUKTAB.
    Internal Table to store Fiscal year Data .
    DATA:    BEGIN OF GJATAB OCCURS 5,
               PERIV             LIKE T001-PERIV,    " Fiscal Year Variant
               GJAHR             LIKE KNC1-GJAHR,    " Fiscal Year
               MONAT             LIKE T009-ANZBP,    "
               ANZBP             LIKE T009-ANZBP,    " Number of posting periods
             END   OF GJATAB.
    *Main Output internal table to be used to store credit history Information
    DATA : BEGIN OF I_CINFO occurs 0,
                 KUNNR TYPE   KNB1-KUNNR,     " Customer
                 KNKLI TYPE   KNKK-KNKLI,     " Customer's account number with credit limit reference
                 KKBER TYPE   KNKK-KKBER,     " Credit Control Area
                 CTLPC TYPE   KNKK-CTLPC,     " Risk Category
                 KLIMK TYPE   KNKK-KLIMK,     " Credit Limit
                 SBGRP TYPE   KNKK-SBGRP,     " Credit representative group for credit management
                 ERDAT TYPE   KNKK-ERDAT,     " Created On
                 DTREV TYPE   KNKK-DTREV,     " Last Internal Review
                 REVDB TYPE   KNKK-REVDB,     " Last External Review
                 SALDO TYPE   RF42B-SALDO,    " Balance
                 DSOIN TYPE   RF02L-DSOIN,    " DSO
                 H06SA TYPE   RF035-H06SA,    " Highest Balance at the end of 6 Months
                 H06JA TYPE   RF035-H06JA,    " Year highest Balance 6 Months
                 H06MO TYPE   RF035-H06MO,    " Month OF hihest Balance 6 Months
                 H12SA TYPE   RF035-H12SA,    " Highest Balance at the end of 12 Months
                 H12JA TYPE   RF035-H12JA,    " Year highest Balance 12 Months
                 H12MO TYPE   RF035-H12MO,    " Month OF hihest Balance 12 Months
                 UMP2U TYPE   RF42B-UMP2U,    " Sales from the current Year
                 UMP1U TYPE   RF42B-UMP1U,    " Sales from the Previous Year
                 SFAEL TYPE   RF035-SFAEL,    " Total Past Due Open Item
                 SFAE1 TYPE   RF035-SFAE1,    " Aging buckets 0-15
                 SFAE2 TYPE   RF035-SFAE2,    " Aging buckets 16-30
                 SFAE3 TYPE   RF035-SFAE3,    " Aging buckets 31-60
                 SFAE4 TYPE   RF035-SFAE4,    " Aging buckets 60-90
                 SFAE5 TYPE   RF035-SFAE5,    " Aging buckets Over 90
          END Of I_CINFO.
    DATA : BEGIN OF S_CINFO ,
                 KUNNR TYPE   KNB1-KUNNR,     " Customer
                 KNKLI TYPE   KNKK-KNKLI,     " Customer's account number with credit limit reference
                 KKBER TYPE   KNKK-KKBER,     " Credit Control Area
                 CTLPC TYPE   KNKK-CTLPC,     " Risk Category
                 KLIMK TYPE   KNKK-KLIMK,     " Credit Limit
                 SBGRP TYPE   KNKK-SBGRP,     " Credit representative group for credit management
                 ERDAT TYPE   KNKK-ERDAT,     " Created On
                 DTREV TYPE   KNKK-DTREV,     " Last Internal Review
                 REVDB TYPE   KNKK-REVDB,     " Last External Review
                 SALDO TYPE   RF42B-SALDO,    " Balance
                 DSOIN TYPE   RF02L-DSOIN,    " DSO
                 H06SA TYPE   RF035-H06SA,    " Highest Balance at the end of 6 Months
                 H06JA TYPE   RF035-H06JA,    " Year highest Balance 6 Months
                 H06MO TYPE   RF035-H06MO,    " Month OF hihest Balance 6 Months
                 H12SA TYPE   RF035-H12SA,    " Highest Balance at the end of 12 Months
                 H12JA TYPE   RF035-H12JA,    " Year highest Balance 12 Months
                 H12MO TYPE   RF035-H12MO,    " Month OF hihest Balance 12 Months
                 UMP2U TYPE   RF42B-UMP2U,    " Sales from the current Year
                 UMP1U TYPE   RF42B-UMP1U,    " Sales from the Previous Year
                 SFAEL TYPE   RF035-SFAEL,    " Total Past Due Open Item
                 SFAE1 TYPE   RF035-SFAE1,    " Aging buckets 0-15
                 SFAE2 TYPE   RF035-SFAE2,    " Aging buckets 16-30
                 SFAE3 TYPE   RF035-SFAE3,    " Aging buckets 31-60
                 SFAE4 TYPE   RF035-SFAE4,    " Aging buckets 60-90
                 SFAE5 TYPE   RF035-SFAE5,    " Aging buckets Over 90
          END Of s_cinfo.
    *Internal table to hold month-wise balance.
    DATA:    BEGIN OF SALTAB OCCURS 12,
               LNUMM(2)     TYPE N,             " Month
               SALDO        LIKE RF42B-SALDO,   " Balance
             END   OF SALTAB.
    *Internal table used for computing the Balance fields
    DATA:    BEGIN OF SALDO,
               UML01             LIKE KNC1-UM01S,
               UML02             LIKE KNC1-UM01S,
               UML03             LIKE KNC1-UM01S,
               UML04             LIKE KNC1-UM01S,
               UML05             LIKE KNC1-UM01S,
               UML06             LIKE KNC1-UM01S,
               UML07             LIKE KNC1-UM01S,
               UML08             LIKE KNC1-UM01S,
               UML09             LIKE KNC1-UM01S,
               UML10             LIKE KNC1-UM01S,
               UML11             LIKE KNC1-UM01S,
               UML12             LIKE KNC1-UM01S,
             END   OF SALDO.
    Structure to hold Bal fields ------ -------
    DATA:    BEGIN OF SKNKK,
               KUNNR             LIKE KNA1-KUNNR,  " Customer Number 1: Debitor
               KONTO             LIKE KNKK-KUNNR,
               SFAE1             LIKE RF035-SFAE1, " Aging buckets 0-15
               SFAE2             LIKE RF035-SFAE2, " Aging buckets 16-30
               SFAE3             LIKE RF035-SFAE3, " Aging buckets 30-60
               SFAE4             LIKE RF035-SFAE4, " Aging buckets 60-90
               SFAE5             LIKE RF035-SFAE5, " Aging buckets Over 90
               SFAEL             LIKE RF035-SFAEL, " Total Due of Items
               UML01             LIKE KNC1-UM01S,
               UML02             LIKE KNC1-UM01S,
               UML03             LIKE KNC1-UM01S,
               UML04             LIKE KNC1-UM01S,
               UML05             LIKE KNC1-UM01S,
               UML06             LIKE KNC1-UM01S,
               UML07             LIKE KNC1-UM01S,
               UML08             LIKE KNC1-UM01S,
               UML09             LIKE KNC1-UM01S,
               UML10             LIKE KNC1-UM01S,
               UML11             LIKE KNC1-UM01S,
               UML12             LIKE KNC1-UM01S,
               UMP1U             LIKE RF42B-UMP1U, " Sales from the Previous Year
               UMP2U             LIKE RF42B-UMP2U, " Sales from the current Year
               SALDO             LIKE RF42B-SALDO, " Balance
             END   OF SKNKK.
    DATA :  BEGIN OF ICUST1 OCCURS 0,
               KUNNR             TYPE KNA1-KUNNR,    "For Customer Filter.
            END   OF ICUST1.
    **Internal table to hold fiscal varriants
    DATA: BEGIN OF LT_PERIODS OCCURS 12,
             PERIOD LIKE BSID-MONAT,
             GJAHR  LIKE KNC1-GJAHR,
           END OF LT_PERIODS.
    **Constants
    constants :  BUKRS1 TYPE KNB1-BUKRS VALUE '1000',
                 BUKRS2 TYPE KNB1-BUKRS VALUE '1031',
                 Recs   Type i value '200',
                 B_count type i value '2'.
          INITIALIZATION
    INITIALIZATION.
      IF RASID IS INITIAL.
        SELECT * FROM TRAS.
          EXIT.
        ENDSELECT.
        IF SY-SUBRC = 0.
          RASID = TRAS-RASID.
        ENDIF.
      ENDIF.
    SELECTION-SCREEN
      parameters : p_path type rlgrap-filename default 'C:\Documents and Settings\C890971\Desktop\Credit_history.XLS'.
    Start of selection processing
    START-OF-SELECTION.
    **Get Customers for Co. Code 1000 & 1031.
      PERFORM GET_CUST.
    Get  / Compute Credit Information data for Company Codes 1000 & 1031.
      PERFORM GET_CREDIT_DATA.
    End of selection processing
    *END-OF-SELECTION.
    Listing Credit History Data
      PERFORM DOWNLOAD_CREDIT_DATA.
    S U B R O U T I N E S
    *&      Form  GET_CUST
          text
    -->  p1        text
    <--  p2        text
    FORM GET_CUST .
    Get US only Customers.
      Refresh icust.
      Select kunnr from kna1 appending table icust
                                   where Land1 = land.
    **Delete duplicate records
      Delete Adjacent duplicates from icust comparing kunnr.
      if icust[] is not initial.
       Limit the selection some more to Co. Code 1000 & 1031
      As join will cost overhead as compared.
      Select kunnr from knb1 into table icust1
                                  for all entries in icust
                                  where kunnr = icust-kunnr
                                  and   bukrs = bukrs1
                                  OR    bukrs = bukrs2.
    **Delete duplicate records
      Delete Adjacent duplicates from icust1 comparing kunnr.
       endif.
    **Free memory.
      Free icust.
    Credit Control Area
      select * from T001CM into table TCMTAB
                           where bukrs = bukrs1 OR
                                 bukrs = bukrs2.
    ENDFORM.                    " GET_CUST
    *&      Form  GET_CREDIT_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM GET_CREDIT_DATA .
      DATA : L_TEXT(60) TYPE C ,
             Ltext1(50) type C value 'Computing Credit-History Data For',
             Ltext2(10) type C value 'Customers',
             L_PCT type i value '10',
             L_recs type i,
             l_batch_recs type i,
             l_s_rec type i value 1,
             l_recs1(7) type N.
    ***Fetch data from KNKK table
      PERFORM GET_KNKK_DATA  .
    ***Computing Crredit Fields
    **Number of Customers For whom Deatils needed.
      Describe table I_CINFO lines l_recs.
      l_recs1 = l_recs.
      Concatenate Ltext1 l_recs1 Ltext2 into l_text separated by ' '.
      PERFORM GET_PGRESS_INDICATOR USING l_text l_pct.
    ***If records are more than 200000, should be processed  batch-wise
      If l_recs > recs.
        l_batch_recs = abs( l_recs / b_count ).
        Do b_count times.
          loop at i_cinfo INTO S_CINFO from l_S_REC to l_batch_recs.
    **Remember the row
            sytabix = sy-tabix.
    **Compute DSO
            PERFORM GET_DSO_FIELD .
    Compute rest credit history data.
            PERFORM COMPUTE_SFIELDS.
          endloop.
          l_S_REC = l_S_REC + l_batch_recs.
          l_batch_recs = l_batch_recs + l_batch_recs.
          IF l_batch_recs ge l_recs.
            l_batch_recs = l_recs.
          eNDIF.
    Commit up to here to release the DB locks.
          Commit work.
        enddo.
      else.
        loop at i_cinfo INTO S_CINFO.
    **Remember the row
          sytabix = sy-tabix.
    **Compute DSO
          PERFORM GET_DSO_FIELD .
    Compute rest credit history data.
          PERFORM COMPUTE_SFIELDS.
        endloop.
      Endif.
    ENDFORM.                    " GET_CREDIT_DATA
    *&      Form  GET_KNKK_DATA
          text
         -->P_ICUST_KUNNR  text
    FORM GET_KNKK_DATA .
      if icust1[] is not initial.
      SELECT   KUNNR KNKLI KKBER  CTLPC KLIMK
               SBGRP ERDAT DTREV REVDB
               from KNKK into corresponding fields of table I_Cinfo
               for all entries in icust1
               where kunnr = icust1-kunnr.
      Delete Adjacent duplicates from i_cinfo comparing kunnr.
      endif.
    **Free Memory for internal table icust1.
      Free icust1.
    ENDFORM.                    " GET_KNKK_DATA
    **&      Form  GET_DSO_FIELD
          text
    -->  p1        text
    <--  p2        text
    FORM GET_DSO_FIELD .
    ***Determine DSO Parameter
      PERFORM DSO_PARAMETER.
    ***Compute DSO
      CALL FUNCTION 'CUSTOMER_DSO_CALCULATION'
        EXPORTING
          I_KKBER       = s_cinfo-kkber
          I_KUNNR       = s_cinfo-kunnr
          I_ANZBUPER    = T000CM-DSOPP
          I_XCHILDS     = T000CM-DSOCH
          I_ACTBALANCE  = T000CM-DSOAB
        IMPORTING
          E_DSOIN       = RF02L-DSOIN
        EXCEPTIONS
          ERROR_MESSAGE = 1.
    ENDFORM.                    " GET_DSO_FIELD
    *&      Form  DSO_PARAMETER
          text
    -->  p1        text
    <--  p2        text
    FORM DSO_PARAMETER.
      IF T000CM-DSOPP IS INITIAL.
        SELECT SINGLE * FROM T000CM.
        IF SY-SUBRC     EQ 0.
          IF T000CM-DSOPP IS INITIAL.
            T000CM-DSOPP = '003'.
          ENDIF.
        ELSE.
          T000CM-DSOPP = '003'.
          T000CM-DSOCH = ' '.
          T000CM-DSOAB = 'X'.
        ENDIF.
      ENDIF.
    ENDFORM.                    " DSO_PARAMETER
    -->  p1        text
    <--  p2        text
    FORM PERIODE_ERMITTELN_EXC USING
                P03_BUDAT    LIKE SYST-DATUM
                P03_GJAHR    LIKE KNC1-GJAHR
                P03_MONAT    LIKE MONAT.
      CALL FUNCTION 'FI_PERIOD_DETERMINE'
           EXPORTING
                I_BUDAT = P03_BUDAT
                I_PERIV = T001-PERIV
              I_BUKRS = T001-BUKRS
                I_GJAHR = P03_GJAHR
                I_MONAT = P03_MONAT
           IMPORTING
                E_GJAHR = P03_GJAHR
                E_MONAT = P03_MONAT
           EXCEPTIONS
                ERROR_MESSAGE = 1.
    ENDFORM.                    "PERIODE_ERMITTELN_EXC
    *&      Form  COMPUTE_SFIELDS
          text
    -->  p1        text
    <--  p2        text
    FORM COMPUTE_SFIELDS .
    **Compute Balance
      PERFORM GET_SFIELDS .
      S_CINFO-DSOIN = RF02L-DSOIN.
      S_CINFO-SALDO = RF035-SALDO.
      S_CINFO-H06SA = RF035-H06SA.
      S_CINFO-H06JA = RF035-H06JA.
      S_CINFO-H06MO = RF035-H06MO.
      S_CINFO-H12SA = RF035-H12SA.
      S_CINFO-H12JA = RF035-H12JA.
      S_CINFO-H12MO = RF035-H12MO.
      S_CINFO-UMP2U = RF42B-UMP2U.
      S_CINFO-UMP1U = RF42B-UMP1U.
      S_CINFO-SFAEL = RF035-SFAEL.
      S_CINFO-SFAE1 = RF035-SFAE1.
      S_CINFO-SFAE2 = RF035-SFAE2.
      S_CINFO-SFAE3 = RF035-SFAE3.
      S_CINFO-SFAE4 = RF035-SFAE4.
      S_CINFO-SFAE5 = RF035-SFAE5.
    modify..
      MODIFY I_CINFO FROM S_CINFO INDEX sytabix.
      CLEAR: S_CINFO,RF035,RF02L, RF42B.
    ENDFORM.                    " COMPUTE_SFIELDS
          text
         -->P_C_INFO_KUNNR  text
    FORM GET_CUST_BAL_INFO.
      LOOP AT TCMTAB.
        CALL FUNCTION 'FI_COMPANY_CODE_DATA'
          EXPORTING
            I_BUKRS       = TCMTAB-BUKRS
          IMPORTING
            E_T001        = T001
          EXCEPTIONS
            ERROR_MESSAGE = 1.
        IF SY-SUBRC = 0.
          MOVE-CORRESPONDING T001 TO BUKTAB.
          BUKTAB-KKBER = TCMTAB-KKBER.
          COLLECT BUKTAB.
        ENDIF.
      ENDLOOP.
      LOOP AT BUKTAB WHERE PERIV NE SPACE.
        GJATAB-PERIV = BUKTAB-PERIV.
        COLLECT GJATAB.
      ENDLOOP.
      CLEAR: MONAT.
      LOOP AT GJATAB.
        T001-PERIV = GJATAB-PERIV.
        CLEAR: GJAHR, MONAT.
        PERFORM PERIODE_ERMITTELN_EXC USING SY-DATLO GJAHR MONAT.
        CHECK SY-SUBRC = 0.
        GJATAB-GJAHR = GJAHR.
        GJATAB-MONAT = MONAT.
        SELECT SINGLE * FROM T009 WHERE PERIV = GJATAB-PERIV.
        IF SY-SUBRC = 0.
          GJATAB-ANZBP = T009-ANZBP.
        ENDIF.
        MODIFY GJATAB.
      ENDLOOP.
      LOOP AT BUKTAB.
        CHECK NOT ( BUKTAB-PERIV IS INITIAL ).
        READ TABLE GJATAB WITH KEY BUKTAB-PERIV.
        CHECK SY-SUBRC = 0
          AND NOT ( GJATAB-GJAHR IS INITIAL ).
        CALL FUNCTION 'CUSTOMER_BALANCE'
          EXPORTING
            KUNNR      = S_cinfo-kunnr
            BUKRS      = BUKTAB-BUKRS
            GJAHR      = GJATAB-GJAHR
            MONAT      = GJATAB-MONAT
            PERIV      = GJATAB-PERIV
            ANZBP      = GJATAB-ANZBP
            XH6MON     = 'X'
            XH12MON    = 'X'
          IMPORTING
            UMP2U      = RF42B-UMP2U
            VMP2U      = RF42B-UMP1U
            SALDO      = RF035-SALDO
            UML01      = SALDO-UML01
            UML02      = SALDO-UML02
            UML03      = SALDO-UML03
            UML04      = SALDO-UML04
            UML05      = SALDO-UML05
            UML06      = SALDO-UML06
            UML07      = SALDO-UML07
            UML08      = SALDO-UML08
            UML09      = SALDO-UML09
            UML10      = SALDO-UML10
            UML11      = SALDO-UML11
            UML12      = SALDO-UML12
          EXCEPTIONS
            NO_BALANCE = 4.
        IF SY-SUBRC = 0.
          SKNKK-UMP1U = SKNKK-UMP1U + RF42B-UMP1U.
          SKNKK-UMP2U = SKNKK-UMP2U + RF42B-UMP2U.
          SKNKK-SALDO = SKNKK-SALDO + RF035-SALDO.
          SKNKK-UML01 = SKNKK-UML01 + SALDO-UML01.
          SKNKK-UML02 = SKNKK-UML02 + SALDO-UML02.
          SKNKK-UML03 = SKNKK-UML03 + SALDO-UML03.
          SKNKK-UML04 = SKNKK-UML04 + SALDO-UML04.
          SKNKK-UML05 = SKNKK-UML05 + SALDO-UML05.
          SKNKK-UML06 = SKNKK-UML06 + SALDO-UML06.
          SKNKK-UML07 = SKNKK-UML07 + SALDO-UML07.
          SKNKK-UML08 = SKNKK-UML08 + SALDO-UML08.
          SKNKK-UML09 = SKNKK-UML09 + SALDO-UML09.
          SKNKK-UML10 = SKNKK-UML10 + SALDO-UML10.
          SKNKK-UML11 = SKNKK-UML11 + SALDO-UML11.
          SKNKK-UML12 = SKNKK-UML12 + SALDO-UML12.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    "
    *&      Form  GET_SFIELDS
          text
    -->  p1        text
    <--  p2        text
    FORM GET_SFIELDS .
      sknkk-kunnr = S_CINFO-KUNNR.
    **Clear target to store computed values
      CLEAR: RF035.
    **Compute Balance fields
      PERFORM GET_CUST_BAL_INFO.
      REFRESH: SALTAB.
      SALTAB-LNUMM = '01'. SALTAB-SALDO = SKNKK-UML01. APPEND SALTAB.
      SALTAB-LNUMM = '02'. SALTAB-SALDO = SKNKK-UML02. APPEND SALTAB.
      SALTAB-LNUMM = '03'. SALTAB-SALDO = SKNKK-UML03. APPEND SALTAB.
      SALTAB-LNUMM = '04'. SALTAB-SALDO = SKNKK-UML04. APPEND SALTAB.
      SALTAB-LNUMM = '05'. SALTAB-SALDO = SKNKK-UML05. APPEND SALTAB.
      SALTAB-LNUMM = '06'. SALTAB-SALDO = SKNKK-UML06. APPEND SALTAB.
      SALTAB-LNUMM = '07'. SALTAB-SALDO = SKNKK-UML07. APPEND SALTAB.
      SALTAB-LNUMM = '08'. SALTAB-SALDO = SKNKK-UML08. APPEND SALTAB.
      SALTAB-LNUMM = '09'. SALTAB-SALDO = SKNKK-UML09. APPEND SALTAB.
      SALTAB-LNUMM = '10'. SALTAB-SALDO = SKNKK-UML10. APPEND SALTAB.
      SALTAB-LNUMM = '11'. SALTAB-SALDO = SKNKK-UML11. APPEND SALTAB.
      SALTAB-LNUMM = '12'. SALTAB-SALDO = SKNKK-UML12. APPEND SALTAB.
      READ TABLE SALTAB INDEX 1.
      RF035-H06SA = SALTAB-SALDO.
      RF035-H06MO = SALTAB-LNUMM.
      RF035-H12SA = SALTAB-SALDO.
      RF035-H12MO = SALTAB-LNUMM.
    ------ SALTAB ---------------------------------------------
      LOOP AT SALTAB.
        IF  SALTAB-SALDO > RF035-H06SA
        AND SY-TABIX     < 7.
          RF035-H06SA = SALTAB-SALDO.
          RF035-H06MO = SALTAB-LNUMM.
        ENDIF.
        IF  SALTAB-SALDO > RF035-H12SA
        AND SY-TABIX     < 13.
          RF035-H12SA = SALTAB-SALDO.
          RF035-H12MO = SALTAB-LNUMM.
        ENDIF.
      ENDLOOP.
    ------ Period--------------------
      REFRESH LT_PERIODS.
      CLEAR LD_COUNTER.
      READ TABLE BUKTAB INDEX 1.
      IF SY-SUBRC = 0.
        READ TABLE GJATAB WITH KEY BUKTAB-PERIV.
        DO GJATAB-MONAT TIMES
           VARYING LD_PERIOD FROM LD_PERIODS(2) NEXT LD_PERIODS+2(2)
                                                     RANGE LD_PERIODS.
          LT_PERIODS-GJAHR  = GJATAB-GJAHR.
          LT_PERIODS-PERIOD = LD_PERIOD.
          LD_COUNTER = LD_COUNTER + 1.
          APPEND LT_PERIODS.
        ENDDO.
        IF LD_COUNTER LT 12.
          LD_GJAHR = GJATAB-GJAHR - 1.
          CLEAR T009Y.
          SELECT SINGLE * FROM T009Y WHERE PERIV = GJATAB-PERIV
                                       AND GJAHR = LD_GJAHR.
          DO GJATAB-ANZBP TIMES
             VARYING LD_PERIOD FROM LD_PERIODS(2) NEXT LD_PERIODS+2(2)
                                                       RANGE LD_PERIODS.
            IF T009Y-ANZBP > 0.
              CHECK SY-INDEX <= T009Y-ANZBP.
            ENDIF.
            LD_COUNTER = LD_COUNTER + 1.
            LT_PERIODS-GJAHR  = LD_GJAHR.
            LT_PERIODS-PERIOD = LD_PERIOD.
            APPEND LT_PERIODS.
          ENDDO.
        ENDIF.
        IF LD_COUNTER LT 12.
          LD_GJAHR = LD_GJAHR - 1.
          DO GJATAB-ANZBP TIMES
             VARYING LD_PERIOD FROM LD_PERIODS(2) NEXT LD_PERIODS+2(2)
                                                       RANGE LD_PERIODS.
            LD_COUNTER = LD_COUNTER + 1.
            LT_PERIODS-GJAHR  = LD_GJAHR.
            LT_PERIODS-PERIOD = LD_PERIOD.
            APPEND LT_PERIODS.
          ENDDO.
        ENDIF.
        SORT LT_PERIODS BY GJAHR ASCENDING PERIOD ASCENDING.
        LD_COUNTER = LD_COUNTER - 12.
        DO LD_COUNTER TIMES.
          DELETE LT_PERIODS INDEX 1.
        ENDDO.
        SORT LT_PERIODS BY GJAHR DESCENDING PERIOD DESCENDING.
        READ TABLE LT_PERIODS INDEX RF035-H06MO.
        RF035-H06MO = LT_PERIODS-PERIOD.
        RF035-H06JA = LT_PERIODS-GJAHR.
        READ TABLE LT_PERIODS INDEX RF035-H12MO.
        RF035-H12MO = LT_PERIODS-PERIOD.
        RF035-H12JA = LT_PERIODS-GJAHR.
      ENDIF.
    **Compute Due Dates fields
      PERFORM GET_AGING_BUCKETS .
      RF035-SFAE1 = SKNKK-SFAE1.
      RF035-SFAE2 = SKNKK-SFAE2.
      RF035-SFAE3 = SKNKK-SFAE3.
      RF035-SFAE4 = SKNKK-SFAE4 .
      RF035-SFAE5 = SKNKK-SFAE5.
    ENDLOOP.
    ENDFORM.                    " GET_BALANCE_SFIELDS
    *&      Form  GET_AGING_BUCKETS
          text
    -->  p1        text
    <--  p2        text
    FORM GET_AGING_BUCKETS .
      DATA: BEGIN OF LT_BUKRS OCCURS 0,
              BUKRS LIKE T001-BUKRS,
            END OF LT_BUKRS.
      DATA: BEGIN OF LT_BUKTAB OCCURS 0,
              BUKRS LIKE T001-BUKRS,
              WAERS LIKE T001-WAERS,
              KKBER LIKE T014-KKBER,
            END OF LT_BUKTAB.
      DATA: LD_LINES LIKE SY-TABIX.
    *...performance optimization: for more than one company codes check....*
    *...if balances exist and avoid selection of open items, if they don't.*
    *...exist..............................................................*
      REFRESH LT_BUKRS.
      REFRESH LT_BUKTAB.
      DESCRIBE TABLE BUKTAB LINES LD_LINES.
      IF LD_LINES GT 1.
        SELECT DISTINCT BUKRS APPENDING CORRESPONDING FIELDS
                                        OF TABLE LT_BUKRS
                              FROM KNC1 FOR ALL ENTRIES IN BUKTAB
                        WHERE BUKRS = BUKTAB-BUKRS AND
                              KUNNR = Sknkk-KUNNR.
        SELECT DISTINCT BUKRS APPENDING CORRESPONDING FIELDS
                                        OF TABLE LT_BUKRS
                              FROM KNC3 FOR ALL ENTRIES IN BUKTAB
                        WHERE BUKRS = BUKTAB-BUKRS AND
                              KUNNR = Sknkk-KUNNR.
        SORT LT_BUKRS.
        DELETE ADJACENT DUPLICATES FROM LT_BUKRS.
        LOOP AT LT_BUKRS.
          LOOP AT BUKTAB WHERE BUKRS = LT_BUKRS-BUKRS.
            MOVE-CORRESPONDING BUKTAB TO LT_BUKTAB.
            APPEND LT_BUKTAB.
          ENDLOOP.
        ENDLOOP.
      ELSE.
        READ TABLE BUKTAB INDEX 1.
        MOVE-CORRESPONDING BUKTAB TO LT_BUKTAB.
        APPEND LT_BUKTAB.
      ENDIF.
    *...process company codes for customer given by interface..........*
      LOOP AT LT_BUKTAB WHERE KKBER = s_cinfo-KKBER.
        CALL FUNCTION  'CUSTOMER_DUE_DATE_ANALYSIS'
             EXPORTING  BUKRS   = LT_BUKTAB-BUKRS
                       KKBER   = ' '
                        KKBER   = s_cinfo-KKBER
                        KUNNR   = Sknkk-KUNNR
                        RASID   = RASID
             IMPORTING  SFAE1   = RF035-SFAE1
                        SFAE2   = RF035-SFAE2
                        SFAE3   = RF035-SFAE3
                        SFAE4   = RF035-SFAE4
                        SFAE5   = RF035-SFAE5
                        SFAEL   = RF035-SFAEL
             EXCEPTIONS NO_OPEN_ITEMS = 4.
        IF SY-SUBRC = 0.
    *--  RF035 -
          SKNKK-SFAE1 = SKNKK-SFAE1 + RF035-SFAE1.
          SKNKK-SFAE2 = SKNKK-SFAE2 + RF035-SFAE2.
          SKNKK-SFAE3 = SKNKK-SFAE3 + RF035-SFAE3.
          SKNKK-SFAE4 = SKNKK-SFAE4 + RF035-SFAE4.
          SKNKK-SFAE5 = SKNKK-SFAE5 + RF035-SFAE5.
          SKNKK-SFAE5 = SKNKK-SFAE5 + RF035-SFAE5.
          SKNKK-SFAEL = SKNKK-SFAEL + RF035-SFAEL.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " GET_AGING_BUCKETS
    *&      Form  header
    This Subroutine gets data for displaying title                     *
    There are no interface parameters to be passed to this subroutine. *
    FORM header .
      wa_final-string = text-000.  APPEND wa_final TO i_final.
      wa_final-string = text-001.  APPEND wa_final TO i_final.
      wa_final-string = text-002.  APPEND wa_final TO i_final.
      wa_final-string = text-003.  APPEND wa_final TO i_final.
      wa_final-string = text-004.  APPEND wa_final TO i_final.
      wa_final-string = text-005.  APPEND wa_final TO i_final.
      wa_final-string = text-006.  APPEND wa_final TO i_final.
      wa_final-string = text-007.  APPEND wa_final TO i_final.
      wa_final-string = text-008.  APPEND wa_final TO i_final.
      wa_final-string = text-009.  APPEND wa_final TO i_final.
      wa_final-string = text-010.  APPEND wa_final TO i_final.
      wa_final-string = text-011.  APPEND wa_final TO i_final.
      wa_final-string = text-012.  APPEND wa_final TO i_final.
      wa_final-string = text-013.  APPEND wa_final TO i_final.
      wa_final-string = text-014.  APPEND wa_final TO i_final.
      wa_final-string = text-015.  APPEND wa_final TO i_final.
      wa_final-string = text-016.  APPEND wa_final TO i_final.
      wa_final-string = text-017.  APPEND wa_final TO i_final.
      wa_final-string = text-018.  APPEND wa_final TO i_final.
      wa_final-string = text-019.  APPEND wa_final TO i_final.
      wa_final-string = text-020.  APPEND wa_final TO i_final.
      wa_final-string = text-021.  APPEND wa_final TO i_final.
      wa_final-string = text-022.  APPEND wa_final TO i_final.
      wa_final-string = text-023.  APPEND wa_final TO i_final.
      wa_final-string = text-024.  APPEND wa_final TO i_final.
    ENDFORM.                               " header
    *&      Form  DOWNLOADCREDITDATA
          text
         -->P_P_PATH  text
    FORM DOWNLOADCREDITDATA  USING P_PATH.
      DATA:
          lw_file2 TYPE string .           " File Path
      lw_file2 = p_PATH.
      CALL FUNCTION 'GUI_DOWNLOAD'
         EXPORTING
      BIN_FILESIZE                    = BIN_FILESIZE
           filename                        = lw_file2
           filetype                        = 'DBF'
      APPEND                          = ' '
       write_field_separator           = ' '
      HEADER                          = '00'
      TRUNC_TRAILING_BLANKS           = 'X'
      WRITE_LF                        = 'X'
       COL_SELECT                      = 'X'
      COL_SELECT_MASK                 = ' '
      DAT_MODE                        = 'X'
      CONFIRM_OVERWRITE               = ' '
      NO_AUTH_CHECK                   = ' '
      CODEPAGE                        = ' '
      IGNORE_CERR                     = ABAP_TRUE
      REPLACEMENT                     = '#'
      WRITE_BOM                       = ' '
      TRUNC_TRAILING_BLANKS_EOL       = 'X'
      WK1_N_FORMAT                    = '0'
      WK1_N_SIZE                      = ' '
      WK1_T_FORMAT                    = ' '
      WK1_T_SIZE                      = ' '
    IMPORTING
      FILELENGTH                      = FILELENGTH
         TABLES
           data_tab                        = I_CINFO
           fieldnames                      = i_final
         EXCEPTIONS
           file_write_error                = 1
           no_batch                        = 2
           gui_refuse_filetransfer         = 3
           invalid_type                    = 4
           no_authority                    = 5
           unknown_error                   = 6
           header_not_allowed              = 7
           separator_not_allowed           = 8
           filesize_not_allowed            = 9
           header_too_long                 = 10
           dp_error_create                 = 11
           dp_error_send                   = 12
           dp_error_write                  = 13
           unknown_dp_error                = 14
           access_denied                   = 15
           dp_out_of_memory                = 16
           disk_full                       = 17
           dp_timeout                      = 18
           file_not_found                  = 19
           dataprovider_exception          = 20
           control_flush_error             = 21
      IF sy-subrc <> 0.
    Messege
      ENDIF.                               " IF sy-subrc EQ 0
    ENDFORM.                    " DOWNLOADCREDITDATA
    *&      Form  DOWNLOAD_CREDIT_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM DOWNLOAD_CREDIT_DATA .
      PERFORM HEADER.
      PERFORM DOWNLOADCREDITDATA USING P_PATH.
    ENDFORM.                    " DOWNLOAD_CREDIT_DATA
    *&      Form  GET_PGRESS_INDICATOR
          text
         -->P_L_TEXT  text
         -->P_L_PCT  text
    FORM GET_PGRESS_INDICATOR  USING    L_TEXT
                                        L_PCT.
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
        EXPORTING
          PERCENTAGE = l_pct
          TEXT       = l_TEXT.
    ENDFORM.                    " GET_PGRESS_INDICATOR

    If you are just Downloading to a Flat file then why dont you have logic in place for the program to dump the data read into  the file to that point depending on any criteria like accounts or customer then clear the internal table and run it in the back ground.
    try to use cursor to read the records from the table which will make it a bit more efficient than plain select stement.

  • Comapare internal tables which are in tree format

    Hi guys,
    Consider internal table
         level | material-no.|quantity
          1 | mat-1 |              10
          2  |             mat-5  |             1
          3            |   mat-2    |           1
          3   |   mat-4  |      12
          2    |  mat-12      |  11
          3    |  mat-15      |  12
    ................................>mat1  ends here..it contains mat5 and mat 12 which in turn contain          
    .......................mat2 & 4 and mat 15 respectively.
          1    |  mat-8     |    1
          2    |  mat-6     |     3
          2    |  mat-100    |    5
    ......................................>mat 8 ends here
          1  |    mat -6    |    13
    .......................................>mat 6 ends here
      This data is in one internal table, here there are 3 main materials (1,8,6) which are in-turn made of other materials.
    material at level 1 is made of materials at level 2
      and in-turn materials at level2 are made up of materials at level3 .
    Now same material can exist at different levels ...
    What would be the efficient way to compare two such internal tables and comparisons are done wrt quantity but level  and hierarchy at which material exits matters and
    comparison shuld be done at each level .
    if both materials  are in same hierarchy in both tables but diff in quantity then they are unequal .
    if both materials are in same hierarchy  in both tables and equal  in quantity then they are equal .
    if that material exist in one but doesnot exist in other table in similar hierarchy then its rendered as
    not found.
    many thanks in advance.

    Hi Anurag,
    Thanks for the reply but the number of levels is not always 3(it completely depends on data) .I came up with one solution --what I have done is , created one more column <b>HPATH</b> in the internal table and kept hierarchy relationship ..i.e
    level| material| qty | HPATH(hierarchy path)
    1 | mat-1 | 10 | mat-1
    2 | mat-5 | 1 | mat-1 2 mat-5
    3 | mat-2 | 1 | mat-1 2 mat-5 3 mat-2
    3 | mat-4 | 12 | mat-1 2 mat-5 3 mat-4
    2 | mat-12 | 11 | mat-1 2 mat-12
    3 | mat-15 | 12 | mat-1 2 mat-12 3 mat-15
    1 | mat-8 | 1 | mat-8
    2 | mat-6 | 3 | mat-8 2 mat-6
    2 | mat-100 | 5 | mat-8 2 mat-100
    2 and 3 are the path seperates..which indicate the level..
    Thus I get key as unique for each material depending on its position in heirarchy ..
    Then I looped wrt one  table and read data form other table with HPATH as key  and compared it .
    This solved it...
    The number of levels doesnot matter in this solution...
    Thanks once again for replying to my post. I would be to  happy  to put up the code if u want..

  • How to find list of internal tables while debugging

    Hi Experts,
      I am debugging a block of an ABAP program( User Exit ). Is there any facility to see what are the internal tables, work areas are available for that particular block? Can I see it new debugger? Because I don't know from which internal table I can take a particular value, which I need to populate in an user exit.
    Thanks and regards,
    Venkat.

    hi,
    you can find the exact  answer here :
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/840ad679-0601-0010-cd8e-9989fd650822#q-6
    under heading List of internal tables while debugging
    regards
    rahul

  • How to Convert internal table data into text output and send mail in ABAP

    Hi All,
    Good Morning.
    Taking a glance at a code that converts internal table data to an Excel file in ABAP. also checked how to send this excel to mailing list as attachment.
    But thought of doing it without excel.
    I mean, I have an internal table which contains fields of all types (character,integer,date,time). Since it is only around 4 to 5 rows in it (output),why to convert it to excel. not required!!.  Instead I  want to send this output to User's mails as Normal mail body with No attachments.
    Could anybody please suggest me a way as to how to send internal table data as a mail ( not as an excel or PDF etc).
    as of now my findings are, it is quite complex to convert internal table data to email (Text) format. but i believe if there is some way of doing it.
    Best Regards
    Dileep VT

    here's something I have used in the past where we send out information about failed precalculation settings (which are stored in internal table gt_fail)
    notice we use gt_text as "mail body"
    TRY.
    *     -------- create persistent send request ------------------------
           gv_send_request = cl_bcs=>create_persistent( ).
    *     -------- create and set document -------------------------------
    *     create text to be sent
           wa_line = text-001.
           APPEND wa_line TO gt_text.
           CLEAR wa_line.
           APPEND wa_line TO gt_text.
           LOOP AT gt_fail ASSIGNING <fs_fail>.
             MOVE <fs_fail>-retry_count TO gv_count.
             CONCATENATE text-002
                         <fs_fail>-setting_id
                         text-003
                         gv_count
                         INTO wa_line SEPARATED BY space.
             APPEND wa_line TO gt_text.
             CLEAR wa_line.
           ENDLOOP.
           APPEND wa_line TO gt_text.
           wa_line = text-007.
           APPEND wa_line TO gt_text.
    *     create actual document
           gv_document = cl_document_bcs=>create_document(
                           i_type    = 'RAW'
                           i_text    = gt_text
                           i_length  = '12'
                           i_subject = 'Failed Precalculation Settings!' ).
    *     add document to send request
           CALL METHOD gv_send_request->set_document( gv_document ).
    *     --------- set sender -------------------------------------------
           gv_sender = cl_sapuser_bcs=>create( sy-uname ).
           CALL METHOD gv_send_request->set_sender
             EXPORTING
               i_sender = gv_sender.
    *     --------- add recipient (e-mail address) -----------------------
           LOOP AT s_email INTO wa_email.
             MOVE wa_email-low TO gv_email.
             gv_recipient = cl_cam_address_bcs=>create_internet_address(
                                               gv_email ).
             CALL METHOD gv_send_request->add_recipient
               EXPORTING
                 i_recipient = gv_recipient
                 i_express   = 'X'.
           ENDLOOP.
    *     ---------- set to send immediately -----------------------------
           CALL METHOD gv_send_request->set_send_immediately( 'X' ).
    *     ---------- send document ---------------------------------------
           CALL METHOD gv_send_request->send(
             EXPORTING
               i_with_error_screen = 'X'
             RECEIVING
               result              = gv_sent_to_all ).
           IF gv_sent_to_all = 'X'.
             WRITE text-004.
           ENDIF.
           COMMIT WORK.
    *   exception handling
         CATCH cx_bcs INTO gv_bcs_exception.
           WRITE: text-005.
           WRITE: text-006, gv_bcs_exception->error_type.
           EXIT.
       ENDTRY.
    with the following declarations
    * TABLES                                                               *
    TABLES:
       adr6,
       rsr_prec_sett.
    * INTERNAL TABLES & WORK AREAS                                         *
    DATA:
       gt_fail          TYPE SORTED TABLE OF rsr_prec_sett
                             WITH UNIQUE KEY setting_id run_date,
       gt_text          TYPE bcsy_text,
       wa_fail          LIKE LINE OF gt_fail,
       wa_line(90)      TYPE c.
    FIELD-SYMBOLS:
       <fs_fail>        LIKE LINE OF gt_fail.
    * VARIABLES                                                            *
    DATA:
       gv_count(4)      TYPE n,
       gv_send_request  TYPE REF TO cl_bcs,
       gv_document      TYPE REF TO cl_document_bcs,
       gv_sender        TYPE REF TO cl_sapuser_bcs,
       gv_recipient     TYPE REF TO if_recipient_bcs,
       gv_email         TYPE adr6-smtp_addr,
       gv_bcs_exception TYPE REF TO cx_bcs,
       gv_sent_to_all   TYPE os_boolean.
    * SELECTION-SCREEN                                                     *
    SELECT-OPTIONS:
       s_email          FOR adr6-smtp_addr NO INTERVALS MODIF ID sel.
    DATA:
       wa_email         LIKE LINE OF s_email.

  • How to pass data from dynamic internal table to standard internal table

    hi experts,
    below is the piece of code which i have used in my requirement but the data is not moved.
    LOOP AT <tab> ASSIGNING <tab1>.
      MOVE-CORRESPONDING <tab1> TO wa.
      append wa TO  gt_outtab.
    ENDLOOP.
    here
    <tab> - dynamic internal table.
    <tab1>-dynamic internal table work area.
    gt_outtab - standard internal table.
    wa- standard internal table work area.
    i am not getting what additional thing i have to write.
    pls help me in this regard.
    thankx in advance.
    soham.p.

    Hello soham p ,
    I am also using the same logic but in my program it is working fine so you declare the fieldsymols like this and try and also check the dynamic internal contain the data or not.
    FIELD-SYMBOLS : <y_i_table>  TYPE STANDARD TABLE,
                                 <y_wa_table> TYPE ANY.
      LOOP AT <y_i_table> ASSIGNING <y_wa_table>.
        MOVE-CORRESPONDING <y_wa_table> TO y_wa_vfscaid.
        APPEND y_wa_vfscaid TO y_i_vfscaid.
        CLEAR y_wa_vfscaid.
      ENDLOOP.

  • Using internal table in screen painter

    hi all,
    may i know why i not able to use the same internal table / working area if i have made changes to the column in the internal table. eg, i change field A, B, C to field X, Y, Z in internal table. i face the problem in the table control wizard when i  recreate the table control referring to the internal table which i have changed the column,
    i even changed the internal table and working area name but still cannot.
    may i know why?
    thx

    hi all,
    any help?
    thx

  • Why using workarea for internal table is better in performance

    Please tell me
    why using workarea for internal table is better in performance

    Hi Vineet ,
      Why would we choose to use an internal table without a header line when it is easier to code one  with a header line?
    it has following reason.
    1)Separate Internal Table Work Area:
         The work area (staging area) defined for the internal table   is not limited to use with just one internal table.
    take ex-
    Suppose you want two internal tables for EMPLOYEE – one to contain all records and one to contain only those records where country = ‘USA’.  You could create both of these internal tables without header lines and use only one work area to load data into both of them. You would append all records from the work area into the first internal table.  You would conditionally append the ‘USA’ records from the same work area into the second internal table.
    2)  Performance Issues:  Using an internal table without a header line is more efficient than one  with a header line
    3) Nested Internal Tables:  If you want to include an internal table within a structure or another   internal table, you must use one without a header line.
    If this one is helpful ,then rewards me
    Regards
    Shambhu

  • Internal table maximum records when occurs 0

    hi experts,
    i am using the internal table upload data,
    at a time it can hold only 10000 recods only ?
    how can i capture more than this.
    thanks&regards,
    srinivas

    Try this way.
    Create a structure with TYPES statement,
    Create internal Table & work area with DATA statement.
    Eg:-
    TYPES : BEGIN OF ty_itab,
                    field1 TYPE mara-matnr,
                    field2 TYPE mara-mtart,
                  END OF ty_itab.
    DATA : it_itab TYPE TABLE OF ty_itab,
                wa_itab TYPE ty_itab.
    Now fill the records into that internal table.
    When you want to read use
    LOOP AT it_ita INTO wa_itab.
    ENDLOOP.
    Regards
    Bala Krishna

  • Accessing Global Internal Table in Field Routine Level

    I am working on a transformation. I have created a Global Internal Table with the structure of my Source Target + extra fields not in my source target. In the start routine of the transformation I am first copying all corresponding fields from SOURCE_PACKAGE to internal table and then finally doing a lot of manipulations and modifying and appending the internal table with data now ready for populating to target.
    I want to populate the target fields at field routine level by  the data present in the Global internal table. Can you please tell me how to code here. If data was being read by SOURCE_PACKAGE, I would have read the value of SOURCE_FIELDS - (Value). But incase of value to be read from Global Internal Table, can I refer to the internal table work area directly. Thanks.
    Global Internal Table - G_ITAB
    Work Area - WA_G_ITAB
    Is the below correct ?
    Result = WA_G_ITAB-(Field Name).

    Let me understand this with an example as I am still not clear. Suppose I am loading to a DSO having 17 Key Fields say K1, K2, K3.........K17.
    And if the 3.5x logic is
    DATA : L1 LIKE COMM_STRUCTURE-amt.
      CLEAR L1 .
      IF COMM_STRUCTURE-CHK = '222'
       OR COMM_STRUCTURE-CHK = '333' .
        L1 = COMM_STRUCTURE-amt .
      ENDIF.
      RESULT = L1 .
    Can you tell me the code of the above in BI7 at field level routine now. Please note I need to take data from G_ITAB internal table and that the DSO has 17 key fields?

Maybe you are looking for

  • Change in Assignment Category gives error

    FRM-40735 POST- UPDATE trigger raised unhandled exception ORA- 01403 I am getting the above error when i am trying to change the Assignment Category field of an employee from Junior Staff to Senior Staff. Navigation People> Enter & Maintain> (B)Assig

  • USING LOOKUP FUNCTION IN CHART

    Good Afternoon, I have created a simple chart in SSRS that is sourced from Analysis Services. The Grouping is by Month and the values are just attendances per month. I want to add a 2nd series to this chart using a stored procedure in SQL. Both share

  • Insert PDFs into Power Point with Adobe Reader 10 doesn't work

    Hello, When I try to insert a PDF Document into a Power Point Sheet (Microsoft Office 2003) the following an error occurred: "Die Serveranwendung , die Quelldatei oder das Element konnte nicht gefunden werden oder ein unbekannter Fehler wurde zurückg

  • How do I get all of the options to appear on a Webroot Toolbar?

    In my Webroot toolbar in Explorer options such as sign in or sign out appear. In Firefox the toolbar is checked in toolbars, and the toolbar is there but not the options.

  • U2413 Color Calibration "Verify USB Connection"

    I am trying to use the Dell Ultrasharp Color Calibration Solution with an x-rite i1 Display Pro. Can't get beyond "Verify USB Connection". The USB cable between the monitor and computer is connected (tried both a USB 3.0 and a 2.0 port). The USB hub