Using internal tables in BI 7 Start routines

Hi All
I tried searching for using internal tables in a start routine in BI 7 could not find the right pointers.
This is what I am trying to do is the following:
In a DSO ZSD_O01  I have a sales order and sales order item number and this DSO also contains the Contract number and the contract Item number.
The DSO structure is as follows:
/BIC/AZSD_O0100
DOC_NUMBER
ITEM
CONTRACT
CITEMNUM
I want to read the data in this DSO into a internal table. But the key fields in this DSO is DOC_NUMBER and ITEM so I want to read this data into a internal table only for the first data package into the internal table. Thereafter I want to lookup into the internal table given the doc_number and ITEM to find the CONTRACT and CITEMNUM.
Can any of you kindly show me how to :
- Read data from a DSO into a internal table
- Read the internal table for the first data package
- How do I make the access in the internal table fast when my lookup in the internal table is not on the
  DSO key columns but on a different key column
Appreciate your help
Thanks
Karen

Hi Karen ,
It will be helpful if you tell your requirement  as the approach you suggested is not looks convincing .May be their is some easy way and we can suggest you better approach
-how to check for source_package = 1
You need to hard code it .
We decide package size at DTP level so you can declare a global variable .let say you have 50000 size of your  package then use global variable as counter and read only when record_count is <= 50000 .
-how to declare the internal table so the values in it exists between different data packages
Declare a global table and select data into it .A global table retain data across  the packages .
- The key on which I need to lookup in the internal table is not the key fields as in the DSO
Its ok .Let say you are doing lookup on A B and C field of DSO1 and the values may duplicate  in your source .then you just need to read the internal table having data from DSO2  with key field  A B C .
Better if you set them as semantic keys at DTP level so that all  duplicate entries of A B  C will appear in same package .
global Declarations
In your start routine you will have this following code :
  TYPES:
      tyt_SC_1        TYPE STANDARD TABLE OF tys_SC_1
                        WITH NON-UNIQUE DEFAULT KEY.
$$ begin of global - insert your declaration only below this line  -
...   insert your code here
$$ end of global - insert your declaration only before this line   -
One question
Why you want to populate values for 1 source package only not for all ?This will be helpful to understand your requirement and may be we can fulfill it in some other manner .
Regards,
Jaya Tiwari

Similar Messages

  • Submititng the program to another program  using internal table values

    Hi All,
    How to Submit from one program to another program using internal table values minimum 7 int tables without using the seletion screen
    thanks
    raj

    Hi All,
    Thank you very much for your inputs.
    i am facing another issue:
    For each 10,000 records it should trigger a job  (we are trying to call a program)  were the validation will be done only through the other program.
    please find the code mentioned below :
    TABLES : but000.
    DATA:  int_bp LIKE but000 OCCURS 0 WITH HEADER LINE.
    data released like BTCH0000-CHAR1.
    DATA: jobnumber LIKE tbtcjob-jobcount, " Job ID and
          jobname LIKE tbtcjob-jobname, " job name.
          startdate LIKE tbtcjob-sdlstrtdt, " Start-time
          starttime LIKE tbtcjob-sdlstrttm, " window specs.
          laststartdate LIKE tbtcjob-laststrtdt,
          laststarttime LIKE tbtcjob-laststrttm,
          job_released LIKE btch0000-char1. " JOB_CLOSE: Was job released?
    DATA : l1 TYPE i,
           b_size TYPE i,
           b_cursor TYPE cursor.
    INITIALIZATION.
      b_size = 5000.
    START-OF-SELECTION.
      OPEN CURSOR WITH HOLD b_cursor
         FOR
         SELECT *
         FROM but000
         WHERE bpkind = 'AA'.
      IF sy-subrc = 0.
        DO.
          FETCH NEXT CURSOR b_cursor INTO TABLE int_bp
                                               PACKAGE SIZE b_size.
    Note : here in this point  we are getting a dump for the second job trigger.
          IF sy-subrc = 0.
            CLEAR jobname.
            CONCATENATE sy-repid sy-datum sy-uzeit INTO jobname.
    export int_bp to memory id 'ABC'.
            CALL FUNCTION 'JOB_OPEN'
                 EXPORTING
                      jobname          = jobname
                 IMPORTING
                      jobcount         = jobnumber.
                EXCEPTIONS
                     cant_create_job  = 1
                     invalid_job_data = 2
                     jobname_missing  = 3
                     OTHERS           = 4
    CALL FUNCTION 'JOB_SUBMIT'
          EXPORTING
               authcknam = sy-uname
               jobname   = jobname
               jobcount  = jobnumber
               report    = 'YTEST_RRR'.
               variant   = lv_variant.
       SUBMIT ytest_rrr
          VIA JOB jobname NUMBER jobnumber
          AND RETURN.
        CALL FUNCTION 'JOB_CLOSE'
          EXPORTING
           event_periodic                    = 'X'
            jobcount                          = jobnumber
            jobname                           = jobname
            strtimmed                         = 'X'
          IMPORTING
            job_was_released                  = released
            else.
            EXIT.
          ENDIF.
        ENDDO.
    calling program :
    REPORT YTEST_RRR .
    data itab1 like but000 occurs 0 with header line.
    data l type i.
    import itab1 from memory id 'ABC' .
    describe table itab1 lines l.
    free memory id 'ABC'.
    write:/ 'total records are:', l.
    Please give your suggestion why its going for  dump in the second iteration.
    thanks in advance.

  • Abap Logic for performance tuning not working when using Internal tables

    Hi,
    I wrote this piece of code that is working correctly that is select SUM of cost from DSO where Plant is the same for Sales Items.
    LOOP AT RESULT_PACKAGE INTO rp.
    SELECT SUM( /N/S_STRDCOST ) FROM /N/ADSP_DPIT00 INTO
    rp-/N/S_STRDCOST
    WHERE /N42/S_SALESITEM = rp-/N42/S_ITEMID AND /N42/S_PLPLANT EQ
    rp-/N42/S_SOURCE.
    MODIFY RESULT_PACKAGE FROM rp.
    Clear rp.
    ENDLOOP.
    Now I try to rewrite it for performance tunning using internal table  but I am getting 0 values. can't figure out whats the problem and been struggling fixing it.
    TYPES : begin of ty_DSO_TABLE,
             /N42/S_STRDCOST TYPE /N/ADSP_DSPC00-/N/S_STRDCOST,
             /N42/S_ITEMID TYPE /N/ADSP_DSPC00-/N/S_ITEMID,
           end of ty_DSO_TABLE.
    DATA: it_DSO_TABLE type hashed table of ty_DSO_TABLE with unique key
    /N/S_ITEMID,
         wa_DSO_TABLE type ty_DSO_TABLE.
    Field-symbols:  <rp> TYPE tys_TG_1.
    LOOP AT RESULT_PACKAGE assigning <rp>.
      clear wa_DSO_TABLE.
    Read table IT_DSO_TABLE into wa_DSO_TABLE with table key /N/S_ITEMID
      = <rp>-/N/S_ITEMID.
      if sy-subrc ne 0.
          select SUM( /N/S_STRDCOST )  into CORRESPONDING
          FIELDS OF wa_DSO_TABLE from
          /N/ADSP_DPIT00 WHERE /N/S_SALESITEM =  <rp>-/N/S_ITEMID AND
          /N/S_PLPLANT EQ <rp>-/N/S_SOURCE.
         if sy-subrc eq 0.
              <rp>-/N/S_STRDCOST = wa_DSO_TABLE-/N/S_STRDCOST.
         endif.
    endif.
    ENDLOOP.
    Any idea whats wrong with the code
    thanks

    Hi Vaidya,
    According to the code which you have written, there is no value in table IT_DSO_TABLE when you are trying to read the values.And after the read statement you have given a condition for sy-subrc. Hence the select statement is actually not even getting executed. *Also you have not assigned the final value back to the ResultPackage.*_
    So Kindly correct your code as follows:
    Data: wa_dso type ty_DSO_TABLE.
    LOOP AT RESULT_PACKAGE assigning <rp>.
    clear wa_DSO_TABLE.
    select SUM( /N/S_STRDCOST ) into CORRESPONDING
    FIELDS OF wa_DSO_TABLE from
    /N/ADSP_DPIT00 WHERE /N/S_SALESITEM = <rp>-/N/S_ITEMID AND
    /N/S_PLPLANT EQ <rp>-/N/S_SOURCE.
    if sy-subrc eq 0.
    <rp>-/N/S_STRDCOST = wa_DSO_TABLE-/N/S_STRDCOST.
    MODIFY RESULT_PACKAGE FROM <rp>.
    endif.
    ENDLOOP.
    Hope this helps you.
    Regards,
    Satyam

  • Report using internal table events

    Hi,
    i have an internal table with  the fields 1. profitcenter 2. company code 3. gl account 4. amount
    for each profit center i need to seggregate accounts based on company code.
    the report should look like the one below.
    please suggest some code using internal table events at new , at end etc. as im not using alv. your help will be rewarded
    regards,
    ravi.
    -Profitcenter-companycodeglaccount-amount---
    -pfcenter1----
    glaccount1-1000---
    glaccount2-2000---
    4444-total--3000---
    glaccount1-4000---
    glaccount2-1000---
    3333-total--5000---
    -profitcentre1*total8000---
    profitcentre2.........

    Hi.
    TYPES: BEGIN OF G_I_DATA,
             PROFIT(4)   TYPE C,
             COMPANY(4)  TYPE C,
             ACCOUNT(10) TYPE C,
             AMOUNT      TYPE P,
           END OF G_I_DATA.
    DATA: G_IT_DATA TYPE TABLE OF G_I_DATA,
          G_WA_DATA TYPE G_I_DATA.
    DATA: G_SUM_COMPANY  TYPE P,
          G_SUM_PROFIT   TYPE P,
          G_AMOUNT       TYPE P.
      G_WA_DATA-PROFIT = '0001'.
      G_WA_DATA-COMPANY = '1111'.
      G_WA_DATA-ACCOUNT = 'ACCOUNT1'.
      G_WA_DATA-AMOUNT = 2000.
      APPEND G_WA_DATA TO G_IT_DATA.
      G_WA_DATA-PROFIT = '0001'.
      G_WA_DATA-COMPANY = '1111'.
      G_WA_DATA-ACCOUNT = 'ACCOUNT2'.
      G_WA_DATA-AMOUNT = 3000.
      APPEND G_WA_DATA TO G_IT_DATA.
      G_WA_DATA-PROFIT = '0001'.
      G_WA_DATA-COMPANY = '2222'.
      G_WA_DATA-ACCOUNT = 'ACCOUNT1'.
      G_WA_DATA-AMOUNT = 4000.
      APPEND G_WA_DATA TO G_IT_DATA.
      G_WA_DATA-PROFIT = '0001'.
      G_WA_DATA-COMPANY = '2222'.
      G_WA_DATA-ACCOUNT = 'ACCOUNT2'.
      G_WA_DATA-AMOUNT = 5000.
      APPEND G_WA_DATA TO G_IT_DATA.
      G_WA_DATA-PROFIT = '0002'.
      G_WA_DATA-COMPANY = '1111'.
      G_WA_DATA-ACCOUNT = 'ACCOUNT1'.
      G_WA_DATA-AMOUNT = 2000.
      APPEND G_WA_DATA TO G_IT_DATA.
      G_WA_DATA-PROFIT = '0002'.
      G_WA_DATA-COMPANY = '1111'.
      G_WA_DATA-ACCOUNT = 'ACCOUNT2'.
      G_WA_DATA-AMOUNT = 3000.
      APPEND G_WA_DATA TO G_IT_DATA.
      G_WA_DATA-PROFIT = '0002'.
      G_WA_DATA-COMPANY = '2222'.
      G_WA_DATA-ACCOUNT = 'ACCOUNT1'.
      G_WA_DATA-AMOUNT = 4000.
      APPEND G_WA_DATA TO G_IT_DATA.
      G_WA_DATA-PROFIT = '0002'.
      G_WA_DATA-COMPANY = '2222'.
      G_WA_DATA-ACCOUNT = 'ACCOUNT2'.
      G_WA_DATA-AMOUNT = 5000.
      APPEND G_WA_DATA TO G_IT_DATA.
      SORT G_IT_DATA BY PROFIT COMPANY ACCOUNT.
      WRITE: /6 'ProfitCenter', 20 'CompanyCode',
              34 'Glaccount', 48 'Amount'.
      WRITE: /6 SY-ULINE(50).
      LOOP AT G_IT_DATA INTO G_WA_DATA.
        AT NEW PROFIT.
          WRITE: /6 G_WA_DATA-PROFIT.
        ENDAT.
        G_AMOUNT = G_WA_DATA-AMOUNT.
        AT NEW ACCOUNT.
          WRITE: /34 G_WA_DATA-ACCOUNT,
                 48  G_AMOUNT.
        ENDAT.
        G_SUM_PROFIT = G_SUM_PROFIT + G_WA_DATA-AMOUNT.
        G_SUM_COMPANY = G_SUM_COMPANY + G_WA_DATA-AMOUNT.
        AT END OF COMPANY.
          WRITE: /20 G_WA_DATA-COMPANY,
                  34 'Totle',
                  48 G_SUM_COMPANY.
          CLEAR G_SUM_COMPANY.
          WRITE: /6 '*******'.
        ENDAT.
        AT END OF PROFIT.
          WRITE: /6 G_WA_DATA-PROFIT,
                  20 'Totle',
                  48 G_SUM_PROFIT.
          CLEAR G_SUM_PROFIT.
          WRITE: /6 '*************************************'.
        ENDAT.
      ENDLOOP.

  • Is there any other option for using internal table in badi

    hi
    i know we cannot use internal table in badi
    but is der any other option
    plz write in d codez too
    with Regards
    Rohan Shetty
    Edited by: Rohan Shetty on May 6, 2008 2:14 PM

    of course you can use internal table in BAdi, do like this.
    data: itab type table of ....
    data: wa type ...
    Example:
    data: itab type (standard, sorted, hashed) table of mara.
    data: wa type mara.
    Or create your own type within the badi.
    types: begin of ty_xxx,
                fielda  type c,
                fieldb  type n,
                fieldc  type d.
    types: end   of ty_xxx
    data: itab type table of ty_xxx.
    data: wa type ty_xxx.
    Edited by: Micky Oestreich on May 6, 2008 2:16 PM

  • Selecting records from DB table with out using internal tables

    hi,
    i need to retrieve values from a database table based on few fields and date as well. however, i need to check whether the date is less or equal to the current date and along with that i should get the appropriate record. how can i do that with out using internal table.
    field1-----date---
    11111----
    20070219
    11111--20070214 <---
    11111----
    20070205
    in the above scenario i should get the second record
    Regards,
    Kranthi.

    Try:
    REPORT ztest MESSAGE-ID 00.
    TABLES bkpf.
    SELECT * FROM bkpf
      UP TO 1 ROWS
      WHERE budat <= sy-datum
      ORDER BY budat DESCENDING.
    ENDSELECT.
    Rob

  • Best way to declare and use internal table

    Hi all,
    As per my knoledge there are various techeniques (Methods) to declare and use the internal tables.
    Please Suggest me the Best way to declaring and using internal table ( WITH EXAMPLE ).
    Please Give the reason as well how the particular method is good ?
    What are benefits of particular method ?
    Thanks in advance.
    Regards
    Raj

    Hello Raj Ahir,
    There are so many methods to declare an internal table.
    Mainly I would like to explain 2 of them mostly used.
    1. Using Work Area and
    2. With header line.
    This with header line concept is not suggestable, because, when we shift the code to oops concept.. it doesn't work... Because OOPS doesn't support the Headerline concept...
    But it all depends on the situation.
    If you are sure that your program doen't make use of the OOPs concept, you can use HEADER LINE concept. If it invols OOPs use WORK AREA concept.
    Now I'l explain these two methods with an example each...
    1. Using Work area.
    TABLES: sflight.
    DATA: it_sflight TYPE TABLE OF sflight.
    DATA: wa_sflight LIKE LINE OF it_sflight.
    SELECT *
      FROM sflight
      INTO it_sflight
      WHERE <condition>.
      LOOP AT it_sflight INTO wa_sflight.
        WRITE / wa_sflight.
      ENDLOOP.
      In this case we have to transfer data into work area wa_sflight.
    We can't access the data from the internal table direclty without work
    area.
    *<===============================================
    2. Using Header line.
      DATA: BEGIN OF it_sflight OCCURS 0,
              carrid LIKE sflight-carrid,
              connid LIKE sflight-connid,
              fldate LIKE sflight-fldate,
            END OF it_sflight.
      SELECT *
        FROM sflight
        INTO it_sflight
        WHERE <condition>.
        LOOP AT it_sflight INTO wa_sflight.
          WRITE / wa_sflight.
        ENDLOOP.
    In this case we can directly access the data from the internal table.
    Here the internal table name represents the header. for each and every
    interation the header line will get filled with new data. If you want to
    represnent the internal table body you can use it_sflight[].
    *<======================================================
    TYPES: BEGIN OF st_sflight,
             carrid LIKE sflight-carrid,
             connid LIKE sflight-connid,
             fldate LIKE sflight-fldate,
           END OF st_sflight.
    DATA: it_sflight TYPE TABLE OF st_sflight,
          wa_sflight LIKE LINE OF it_sflight.
    This is using with work area.
    DATA: it_sflight LIKE sflight OCCURS 0 WITH HEADER LINE.
    This is using header line.
    <b>REWARD THE POINTS IF IT IS HELPFUL.</b>
    Regards
    Sasidhar Reddy Matli.
    Message was edited by: Sasidhar Reddy Matli
            Sasidhar Reddy Matli

  • Compare the elements data of the 2 context nodes using internal table

    Hi,
    How can i compare the elements data of the 2 context nodes using internal table?
    Regards,
    Ronita

    hi ronita,
    just get the nodes data into internal tables and just compare them......
    node1->get_static_attributes_table(importing table = ITAB_node1)
    node2->get_static_attributes_table(importing table = ITAB_node2)
    now u have the data of ur 2 context nodes in 2 different internal tables ..
    just compare them like
    if  ITAB_node1[ ] = ITAB_node2[ ].
    write: / 'itab1 is equal to itab2'..
    endif.
    and u can use as many as comparision operators between these 2 tables to compare them....
    regards....
    srini,,,,

  • Population of sales orders using internal tables

    I am trying to execute a program, where my requirement is to populate all the
    sales orders number using internal tables concept
    I am not sure, whether I am missing portion of logic or logic is incorrect
    Followed is the source code of my program
    tables: vbak.
    data: ztab like standard table of vbak with header line.
    parameters: z_vbeln like vbak-vbeln.
    select * from vbak into ztab where vbtyp = 'c'.
    append ztab.
    endselect.
    write: 30 'sales order' , 50 'order type', 60 'date' , 75 'time'.
    loop at ztab.
    write: /30 ztab-vbeln, 50 ztab-vbtyp, 60 ztab-erdat, 75 ztab-erzet.
    endloop.
    Thanks In Advance!!

    Hi Eshwer,
    Try following code. Use into table concept. It performancewise better than select ...endselect.
    TABLES : vbak.
    DATA : ztab LIKE STANDARD TABLE OF vbak WITH HEADER LINE.
    PARAMETERS : z_vbeln LIKE vbak-vbeln.
    SELECT  *
        INTO TABLE  ztab
        FROM vbak
       WHERE vbtyp = 'c'.
    ***You can add parameter z_vbeln in where clause if required****
    IF sy-subrc EQ 0.
    write: 30 'sales order' , 50 'order type', 60 'date' , 75 'time'.
    LOOP AT ztab.
    write: /30 ztab-vbeln,
              50 ztab-vbtyp,
              60 ztab-erdat,
              75 ztab-erzet.
    ENDLOOP.
    Regards,
    Anil Salekar

  • Using Internal Table in ABAP OO.

    Hi,
         I am using a internal table, I am calling a FM, which require Internal table as its parameter. Since Internal table with header line is not supported in ABAP OO. How to attain this.
    Thanq For Ur time.
    Cheers,
    Sam

    Hi,
    Please look at my example below.
    TYPES: BEGIN OF t_vbak,
              vbeln TYPE vbak-vbeln,
              posnr TYPE vbap-posnr,
              erdat TYPE vbak-erdat,
              ernam TYPE vbak-ernam,
              auart TYPE vbak-auart,
              kunnr TYPE vbak-kunnr,
              vkgrp TYPE vbak-vkgrp,
             END OF t_vbak.
    DATA: gt_vbak     TYPE STANDARD TABLE OF t_vbak,
          gt_vbak_dum LIKE gt_vbak.
    *CLASS DEFINITIONS
    *       CLASS lcl_get_so DEFINITION
    CLASS lcl_get_so DEFINITION.
      PUBLIC SECTION.
        METHODS: get_sales_orders
                    EXPORTING
                       ex_vbak LIKE gt_vbak.
    ENDCLASS.                    "lcl_get_so DEFINITION
    *CLASS IMPLEMENTATIONS
    *       CLASS lcl_get_so IMPLEMENTATION
    CLASS lcl_get_so IMPLEMENTATION.
      METHOD get_sales_orders.
        SELECT vbak~vbeln vbap~posnr vbak~erdat
               vbak~ernam vbak~auart vbak~kunnr
               vbak~vkgrp
          FROM vbak
         INNER JOIN vbap
            ON vbak~vbeln = vbap~vbeln
          INTO TABLE gt_vbak
         WHERE vbak~erdat IN s_erdat
           AND vbak~ernam IN s_ernam
           AND vbak~auart IN s_auart
           AND vbak~vkgrp IN s_vkgrp
           AND vbak~kunnr = p_kunnr.
        IF NOT gt_vbak[] IS INITIAL.
          ex_vbak[] = gt_vbak[].
        ELSE.
          MESSAGE i000 WITH 'No data found for given criteria'.
          LEAVE TO SCREEN 0.
        ENDIF.
      ENDMETHOD.                    "get_sales_orders
    ENDCLASS.                    "lcl_get_so IMPLEMENTATION
    * START-OF-SELECTION                           *
    START-OF-SELECTION.
      DATA: o_get_so         TYPE REF TO lcl_get_so.
      CREATE OBJECT: o_get_so.
    *Get sales orders
        CALL METHOD o_get_so->get_sales_orders
          IMPORTING
            ex_vbak = gt_vbak_dum.
    Hope it helps...
    Please award points if it helps...

  • Using internal table in BAPI

    hello friends,
    I have a scenario where I have to write a BAPI that accepts an input and exports an internal table with several records.
    I am finding it difficult to define an internal table.
    When I try to define it in the EXPORT tab, it says that 'Occur n' is missing.
    If i try to define it in the SOURCE CODE tab using 'data' command, then i can't export it, since
    it says that the internal table definition is already defined.
    So I would appreciate if some one can let me know how to doit. If you have a sample BAPI that you can share I would appreciate it..
    Thanks
    Ram

    check this sample program
      REPORT z_salesorder_create NO STANDARD PAGE HEADING.
    * Order Type
      SELECTION-SCREEN BEGIN OF LINE.
      SELECTION-SCREEN COMMENT 2(20) v_text FOR FIELD p_auart.
      PARAMETERS: p_auart TYPE auart OBLIGATORY  DEFAULT 'ZOR'.
      SELECTION-SCREEN END OF LINE.
    * Sales organization
      SELECTION-SCREEN BEGIN OF LINE.
      SELECTION-SCREEN COMMENT 2(20) v_text1 FOR FIELD p_vkorg.
      PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY  DEFAULT '0081'.
      SELECTION-SCREEN END OF LINE.
    * Distribution channel
      SELECTION-SCREEN BEGIN OF LINE.
      SELECTION-SCREEN COMMENT 2(20) v_text2 FOR FIELD p_vtweg.
      PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY DEFAULT '01'.
      SELECTION-SCREEN END OF LINE.
    * Division.
      SELECTION-SCREEN BEGIN OF LINE.
      SELECTION-SCREEN COMMENT 2(20) v_text3 FOR FIELD p_spart.
      PARAMETERS: p_spart TYPE spart OBLIGATORY default 'RT'.
      SELECTION-SCREEN END OF LINE.
    * Sold-to
      SELECTION-SCREEN BEGIN OF LINE.
      SELECTION-SCREEN COMMENT 2(20) v_text4 FOR FIELD p_sold.
      PARAMETERS: p_sold  TYPE kunnr OBLIGATORY.
      SELECTION-SCREEN END OF LINE.
    * Ship-to
      SELECTION-SCREEN BEGIN OF LINE.
      SELECTION-SCREEN COMMENT 2(20) v_text5 FOR FIELD p_ship.
      PARAMETERS: p_ship  TYPE kunnr OBLIGATORY.
      SELECTION-SCREEN END OF LINE.
      SKIP 1.
    * PO Number
      SELECTION-SCREEN BEGIN OF LINE.
      SELECTION-SCREEN COMMENT 2(20) v_text6 FOR FIELD p_ebeln.
      PARAMETERS: p_ebeln TYPE vbkd-bstkd  OBLIGATORY.
      SELECTION-SCREEN END OF LINE.
    * Plant
      SELECTION-SCREEN BEGIN OF LINE.
      SELECTION-SCREEN COMMENT 2(20) v_text9 FOR FIELD p_plant.
      PARAMETERS: p_plant TYPE werks_d OBLIGATORY DEFAULT '81RT'.
      SELECTION-SCREEN END OF LINE.
    *File selection
      SELECTION-SCREEN BEGIN OF LINE.
      SELECTION-SCREEN COMMENT 2(20) v_text10 FOR FIELD p_infile.
      PARAMETERS: p_infile LIKE rlgrap-filename DEFAULT 'C:\TEMP\SALES.XLS'
                        OBLIGATORY.
      SELECTION-SCREEN END OF LINE.
    * Initialization.
    INITIALIZATION.
       v_text  = 'Order type'.
      v_text1  = 'Sales Org'.
      v_text2  = 'Distribution channel'.
      v_text3  = 'Division'.
      v_text4  = 'Sold-to'.
      v_text5  = 'Ship-to'.
      v_text6  = 'PO Number'.
      v_text9  = 'Plant'.
      v_text10 = 'Select File'.
      TYPES: BEGIN OF t_record ,
               matnr LIKE  itb-value,  "Material Number
               menge LIKE  itb-value,  "Quantity
               i_text LIKE itb-value,  "Item text
             END OF t_record.
      DATA : line TYPE i.
      DATA: BEGIN OF it_data OCCURS 100,
             matnr TYPE rv45a-mabnr,
             menge TYPE rv45a-kwmeng,
             i_text TYPE char200,
            END OF it_data.
      DATA : BEGIN OF i_vbap OCCURS 0,
               vbeln LIKE  vbap-vbeln,
               posnr LIKE  vbap-posnr,
               text  LIKE  rstxt-txline,
             END OF i_vbap.
    * BAPI tables
      DATA: v_vbeln            LIKE vbak-vbeln,
            header             LIKE bapisdhead1,
            headerx            LIKE bapisdhead1x,
            item               LIKE bapisditem  OCCURS 0 WITH HEADER LINE,
            itemx              LIKE bapisditemx OCCURS 0 WITH HEADER LINE,
            partner            LIKE bapipartnr  OCCURS 0 WITH HEADER LINE,
            return             LIKE bapiret2    OCCURS 0 WITH HEADER LINE,
            lt_schedules_inx   TYPE STANDARD TABLE OF bapischdlx
                               WITH HEADER LINE,
            lt_schedules_in    TYPE STANDARD TABLE OF bapischdl
                               WITH HEADER LINE.
    START-OF-SELECTION.
      PERFORM read_excel_file.
    * Header data
    * Sales document type
      header-doc_type = p_auart.
      headerx-doc_type = 'X'.
    * Sales organization
      header-sales_org = p_vkorg.
      headerx-sales_org = 'X'.
    * Distribution channel
      header-distr_chan  = p_vtweg.
      headerx-distr_chan = 'X'.
    * Division
      header-division = p_spart.
      headerx-division = 'X'.
      headerx-updateflag = 'I'.
    *po number
      header-purch_no_c = p_ebeln.
      headerx-purch_no_c = 'X'.
    * Partner data
    * Sold to
      partner-partn_role = 'AG'.
      partner-partn_numb = p_sold.
      APPEND partner.
    * Ship to
      partner-partn_role = 'WE'.
      partner-partn_numb = p_ship.
      APPEND partner.
    * ITEM DATA
      LOOP AT it_data.
        line = sy-tabix.
        itemx-updateflag = 'I'.
    * Material
        item-material = it_data-matnr.
        itemx-material = 'X'.
    * Plant
        item-plant    = p_plant.
        itemx-plant   = 'X'.
    * Quantity
        item-target_qty = it_data-menge.
        itemx-target_qty = 'X'.
        APPEND item.
        APPEND itemx.
    *   Fill schedule lines
        lt_schedules_in-sched_line = line.
        lt_schedules_in-req_qty    = it_data-menge.
        APPEND lt_schedules_in.
    *   Fill schedule line flags
        lt_schedules_inx-sched_line  = line.
        lt_schedules_inx-updateflag  = 'X'.
        lt_schedules_inx-req_qty     = 'X'.
        APPEND lt_schedules_inx.
      ENDLOOP.
    * Call the BAPI to create the sales order.
      CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'
        EXPORTING
          sales_header_in     = header
          sales_header_inx    = headerx
        IMPORTING
          salesdocument_ex    = v_vbeln
        TABLES
          return              = return
          sales_items_in      = item
          sales_items_inx     = itemx
          sales_schedules_in  = lt_schedules_in
          sales_schedules_inx = lt_schedules_inx
          sales_partners      = partner.
    * Check the return table.
      LOOP AT return WHERE type = 'E' OR type = 'A'.
        WRITE :/(72) return-message color 6.
      ENDLOOP.
      IF sy-subrc = 0.
        WRITE: / 'Error in creating document'.
        EXIT.
      ELSE.
    * Commit the work.
        COMMIT WORK AND WAIT.
        WRITE: / 'Document ', v_vbeln, ' created'.
      ENDIF.

  • How to call Subroutines,Standard Text  & using Internal Table in SmartForm

    Hi all,
    need help in the following areas.Its very urgent!
    1.How to CAll Subroutines in Smart Forms
    2.How to CAll Standard Text in Smart Forms
    Situation:
    We have an Internal Table T_SALES with all the data which am going to display in the smartform,How to retrive data from an internal table in Smart forms
    Any Help in this direction would be highly appreciated.
    Regards
    Ramu

    Hi,
      When you are using quantity or currency fields, you have to mentiong the reference fileds in a tab called CURRENCY/QUANTITY FILEDS in the GLOBAL DATA node.
    Specifying a Currency or Quantity Reference
    Use
    In the ABAP Dictionary, you can assign a currency or quantity field to a table field. In the output of these fields, the system can then insert the relevant currency or unit:
    ·        If the value field is in the same table as the corresponding currency or quantity field, the system recognizes the reference automatically, and formats the value field according to the currency or unit in the assigned field.
    ·        If the value field is in a different table from the currency or quantity field, the system cannot recognize this reference automatically.
    In the second case, you must indicate this reference to the system in the form, to ensure that the value field is formatted correctly.
    Procedure
    You want to assign a currency or quantity field in one table (for example, CURTAB) to a value field in another table (for example, VALTAB).
           1.      Create the reference to the currency field by entering the following values:
    -         Field Name: VALTAB-VALUE, if this is the value field of VALTAB that you want to display.
    -         Reference Field: CURTAB-CURRENCY, which is the currency field of CURTAB.
           2.      Under Data Type, specify whether the data type is a currency or quantity.
    Result
    In the output of the PDF-based print form, the system formats the value field VALTAB-VALUE according to the assigned value in the currency or quantity field of the global variable CURTAB-CURRENCY.
    Thanks and Regards,
    Bharat Kumar Reddy.V
    Message was Added by: Bharat Reddy V
    Message was Added by: Bharat Reddy V

  • Use internal table in Smartform

    Hi All,
    I want to use the internal table in program in smartform.
    For that i have declare that table in TABLES attribute of the function module and trying to declare that table in form interface in smartform.I have created one stucture in data dictionary of same type for the associated type of that table.But it showing me error that only table types can be used as reference type for a table parameter.
    Can anybody give me the solution or atleast tell me what is problem?
    Thanks.

    Hi,
    First you define an internal table in your Driver program and populate the same with the data and put it in the Export parameters.
    Then, in your Smartform, in the Form interface parameter's declarations, specify the name which you gave in the Driver program ( the Left hand side name in the interface list of the Function Module ) and specify it as type of the internal table you have used in the Driver program.
    Please define in the same way as mentioned and let me know how it worked for you or still any issues on this.
    Thanks,
    Vishnu.

  • Submit report using internal table

    Hi Experts!!,
    REPORT 1
    TYPES:   BEGIN OF ty_out_table,
             partner LIKE /sapsll/pntbp-partner,
             bpvsy   LIKE /sapsll/pntbp-bpvsy,
             country LIKE adrc-country,
            END OF ty_out_table.
    internal table declaration & definition
    DATA:  gt_out_table TYPE STANDARD TABLE OF ty_out_table
                   WITH KEY partner
                            bpvsy.
    I have data in internal table gt_out_table.
    I want to pass data gt_out_table in report 2. using SUBMIT REPORT.
    How to do that ?
    REPORT 2
    select-options: s_partnr  for  /sapsll/pntbp-bpvsy.
    parameters: p_upd,
                      p_value .
    please suggest.
    Thanks
    Anee

    hai,
    ... WITH SELECTION-TABLE rspar
    Effect
    If you specify this addition, parameters and selection criteria on the selection screen are supplied from an internal table rspar. You must specify an internal table with the row type RSPARAMS for rspar. The structured data type RSPARAMS is defined in the ABAP Dictionary and has the following components, all of which are data type CHAR:
    SELNAME (length 8),
    KIND (length 1),
    SIGN (length 1),
    OPTION (length 2),
    LOW (length 45),
    HIGH (length 45).
    To supply parameters and selection criteria for the selection screen with specific values, the lines in the internal table rspar must contain the following values:
    SELNAME must contain the name of a parameter or selection criterion for the selection screen in block capitals
    KIND must contain the type of selection screen component (P for parameters, S for selection criteria)
    SIGN, OPTION, LOW, and HIGH must contain the values specified for the selection table columns that have the same names as the selection criteria; in the case of parameters, the value must be specified in LOW and all other components are ignored.
    If the name of a selection criterion is repeated in rspar, this defines a selection table containing several lines and passes it on to the selection criterion. If parameter names occur several times, the last value is passed on to the parameter.
    The contents of the parameters or selection tables for the current program can be entered in the table by the function module RS_REFRESH_FROM_SELECTOPTIONS.
    Notes
    In contrast to selection tables, the data types of the components LOW and HIGH in table rspar are always of type CHAR and are converted to the type of the parameter or selection criterion during transfer, if necessary.
    When entering values, you must ensure that these are entered in the internal format of the ABAP values, and not in the output format of the screen display.

  • What are the advantages  using internal tables without headerline.

    hi,
    i have a doubt,please clarify.
    data:itab like &lt;databse table&gt; occurs 0 with header line.
    or
    data:itab like &lt;databse table&gt;occurs 0,
    wa like line type of itab.
    in above two cases , in my view  no difference.
    in first case there will be one workarea will be created with same name itab,
    in second case we are explicitly creating work area.
    ok.
    here my doubt is in what cases it is madatory to create  internal table with  explicitly work area?
    thank in advance.
    venu

    Hi,
    It is a good practice to define a structure for your internal table. Then declare an internal table with the defined structure. Using a workarea to access to the internal table.
    TYPES : BEGIN OF struc_tab,
                      rec1(10) TYPE c,
                  END OF struc_tab.
    DATA : itab TYPE TABLE OF struc_tab,
                wa_itab LIKE LINE OF itab.
    There is no differences, just that we're avoiding declaring using 'With Occurs 0' or 'With Header Line' and in some cases in oo programming, headerline are not allowed.
    Regards,
    Loo

Maybe you are looking for

  • RSEG Accounting document no

    Hi I  want to get the purchase order wise payment  (check no),I have already get the miro document no in rseg,pls tell me how to get the miro accounting document no

  • Displayport v 1.1a?

    Hi all. I have a mid-2009 core2duo 15" Macbook Pro unibody with mini displayport. I want to buy  a monitor and connect it via a displayport cable, but the apparently the monitor I want has a displayport v 1.2. I'm pretty sure the mid-2009 MBPs use Di

  • CS3 - Will not Save, Program Error

    Just ran the CS3 patch and now files are not saving. Getting a "Program Error" when attempting to Save file. Any workarounds? Would like to Save what I have been working on, including layers and masks.

  • Hit "send to..." from drop-down or web page & it launches continuous & unstoppable tabs.

    This problem has been occurring for perhaps 2 months, and was what encouraged me to upgrade to your latest version. But the problem has followed, even tho I uninstalled the other Firefox before I installed the new version. Your "left-click, drop-down

  • Pavilion g6 keyboard problem

    When I press the letter O random other letters come into the text and also letter L. Sometimes it will just open a new tab. I cannot log in as myself or administrator because of it. Have tried cleaning keyboard and a hard reboot but this hasn't worke