Internal table - output

Hi friends,
I have an internal table with the following fields:
salesordernumber   itemnumber   etcetc
I want the output as below:
salesordernumber   itemnumber1
                   itemnumber2
(if the salesordernumber has multiple items, the itemnumber2 should come exactly below itemnumber1)
or just
salesordernumber   itemnumber (and go for the next sales order if it has single item)
Please suggest a code.
Thanks.

Hi Nuren,
Please check this piece of code.
TYPES : BEGIN OF ty_itab,
       f1,
       f2(10),
       END OF ty_itab.
DATA : itab TYPE TABLE OF ty_itab WITH HEADER LINE.
itab-f1 = 'A'.
itab-f2 = 'GANGA'.
APPEND itab.
itab-f1 = 'A'.
itab-f2 = 'GANGA'.
APPEND itab.
itab-f1 = 'B'.
itab-f2 = 'GANGA'.
APPEND itab.
itab-f1 = 'B'.
itab-f2 = 'GANGA'.
APPEND itab.
itab-f1 = 'C'.
itab-f2 = 'GANGA'.
APPEND itab.
LOOP AT itab.
  AT NEW f1.
    WRITE: /5 itab-f1, 10 itab-f2.
  ENDAT.
  WRITE: /10 itab-f2.
ENDLOOP.
Output will be :
A    *************
      GANGA
      GANGA
B     *************
      GANGA
      GANGA
C     *************
      GANGA
Hope this what u require. If found helpful, please do reward.

Similar Messages

  • Convert internal table output to pdf format

    Hi all,
    my query is given below.
    <removed by moderator>
    i need to convert internal table output to Pdf. format
    the Pdf file generating.
    when i am opening the pdf. file shows error like there was an error opening this document . this file cannot be opened because it has no pages.
    please help me.
    thanks in advance.
    Regards,
    Karthikeyan Krishan
    Moderator message: please post only relevant code parts, your posts must contain less than 5000 characters each to preserve formatting.
    Edited by: Thomas Zloch on Mar 30, 2011 12:57 PM

    Hi,
    Check this link where I send data in RAW format as attachment using cl_bcs.
    Open PDF File stored in AL11 and send by email using CL_BCS.
    Regards,
    Ernesto

  • Internal Table output in customer format ; write statement

    Hello All,
    I need help in printing the O/P.
    Currently the program is displaying ALV.
    However I need the O/P to be displayed like.
    FIELDANAME1;FIELDNAME2;FIELDNAME3;....FNZ.
    VALUE1;VALUE2;VALUE3....VZ.
    Code is below - Dynamically it will show the table contents
    according to the tabel name.
    *& Report YREN_FIELDSDISPLAY
    REPORT YREN_FIELDSDISPLAY.
    FIELD-SYMBOLS:
    <f_tab1> TYPE STANDARD TABLE.
    PARAMETERS:
    p_tname TYPE tabname16 OBLIGATORY, " DEFAULT 'MARA' ,
    p_rows(5) TYPE c DEFAULT '200'.
    CLASS lcl_dynamic DEFINITION
    CLASS lcl_dynamic DEFINITION CREATE PRIVATE.
    PUBLIC SECTION.
    CLASS-METHODS:
    check_selection
    EXCEPTIONS invalid_table,
    main
    EXCEPTIONS no_data_found,
    display.
    PRIVATE SECTION.
    TYPE-POOLS: abap.
    CLASS-DATA: tab TYPE REF TO cl_abap_structdescr,
    wa_tab TYPE REF TO cl_abap_structdescr,
    comp_tab TYPE cl_abap_structdescr=>component_table,
    i_tab TYPE REF TO cl_abap_tabledescr,
    i_table TYPE REF TO data.
    ENDCLASS. "lcl_dynamic DEFINITION
    CLASS lcl_dynamic IMPLEMENTATION
    CLASS lcl_dynamic IMPLEMENTATION.
    METHOD check_selection.
    SELECT COUNT( * )
    FROM dd02l
    WHERE tabname = p_tname
    AND as4local = 'A'
    AND tabclass = 'TRANSP'.
    IF sy-subrc = 0.
    RAISE invalid_table.
    ENDIF.
    ENDMETHOD. "check_selection
    METHOD main.
    tab ?= cl_abap_typedescr=>describe_by_name( p_tname ).
    comp_tab = tab->get_components( ).
    wa_tab = cl_abap_structdescr=>create( comp_tab ).
    i_tab = cl_abap_tabledescr=>create( wa_tab ).
    CREATE DATA i_table TYPE HANDLE i_tab.
    ASSIGN i_table->* TO <f_tab1>.
    IF p_rows IS INITIAL.
    p_rows = '50000'.
    ENDIF.
    *Get data
    SELECT * FROM (p_tname)
    INTO TABLE <f_tab1>
    UP TO p_rows ROWS.
    IF sy-subrc EQ 0.
    RAISE no_data_found.
    ENDIF.
    ENDMETHOD. "main
    METHOD display.
    SET TITLEBAR sy-title
    OF PROGRAM sy-cprog
    WITH 'Display table:' p_tname.
    DATA:
    l_gr_alv TYPE REF TO cl_salv_table,
    l_gr_functions TYPE REF TO cl_salv_functions.
    TRY.
    CALL METHOD cl_salv_table=>factory
    IMPORTING
    r_salv_table = l_gr_alv
    CHANGING
    t_table = <f_tab1>.
    CATCH cx_salv_msg . "#EC NO_HANDLER
    ENDTRY.
    l_gr_functions = l_gr_alv->get_functions( ).
    l_gr_functions->set_all( abap_true ).
    l_gr_alv->display( ).
    ENDMETHOD. "display
    ENDCLASS. "lcl_dynamic IMPLEMENTATION
    AT SELECTION-SCREEN.
    CALL METHOD lcl_dynamic=>check_selection
    EXCEPTIONS
    invalid_table = 1.
    IF sy-subrc EQ 0.
    MESSAGE e001(00) WITH
    p_tname ' is not a Transparant Table'.
    ENDIF.
    START-OF-SELECTION.
    CALL METHOD lcl_dynamic=>main
    EXCEPTIONS
    no_data_found = 1.
    IF sy-subrc EQ 0.
    MESSAGE i001(00) WITH 'No data found'.
    LEAVE LIST-PROCESSING.
    ENDIF.
    END-OF-SELECTION.
    CALL METHOD lcl_dynamic=>display.
    Thanks,
    Varun.

    hi varun,
    amandep is correct ...use REUSE_ALV_GRID_DISPLAY .If still you have problem in formatting then go through this code used for ALV display.
    *& Report  ZYOGALVEX1
    REPORT  ZYOGALVEX1.
    type-pools: slis.
    tables: zyogstudent,t001.
    data: itab like zyogstudent occurs 0 with header line.
    data: begin of jtab occurs 0,
          bukrs like t001-bukrs,
          butxt like t001-butxt,
          ort01 like t001-ort01,
          stceg like t001-stceg,
          end of jtab.
    data: field_cat type slis_t_fieldcat_alv,
          xlayout type slis_layout_alv,
          i_sort type slis_t_sortinfo_alv.
    start-of-selection.
      perform get_data.
      perform dis_lay.
      perform dis_sort.
      perform display.
    *&      Form  get_data
          text
    -->  p1        text
    <--  p2        text
    form get_data .
      select * from zyogstudent into table itab.
      select bukrs ort01 stceg butxt  from t001 into corresponding fields of table jtab.
           perform field_init using field_cat.
    endform.                    " get_data
    *&      Form  dis_lay
          text
    -->  p1        text
    <--  p2        text
    form dis_lay .
      xlayout-zebra = 'X'.
      xlayout-no_keyfix = 'X'.
      xlayout-flexible_key = 'X'.
      xlayout-colwidth_optimize = 'skip'.
      xlayout-header_text = 'this is using header text'.
    endform.                    " dis_lay
    *&      Form  dis_sort
          text
    -->  p1        text
    <--  p2        text
    form dis_sort .
      data l_sort type slis_sortinfo_alv.
        l_sort-fieldname = 'ZNAME'.
        l_sort-tabname = 'ZYOGSTUDENT'.
        l_sort-spos = 1.
        l_sort-up = 'X'.
        append l_sort to i_sort.
    endform.                    " dis_sort
    *&      Form  field_init
          text
         -->P_FIELD_CAT  text
    form field_init  using    p_field_cat.
      data wa_cat type slis_fieldcat_alv.
           wa_cat-fieldname = 'ZNAME'.
           wa_cat-tabname = 'zyogstudent'.
           wa_cat-outputlen = 25.
           wa_cat-seltext_m = 'ZNAME'.
           wa_cat-just = 'L'.
           append wa_cat to field_cat.
           wa_cat-fieldname = 'ZCLASS'.
           wa_cat-tabname = 'zyogstudent'.
           wa_cat-outputlen = 25.
           wa_cat-seltext_m = 'ZCLASS'.
           wa_cat-just = 'C'.
           append wa_cat to field_cat.
            wa_cat-fieldname = 'ZFEES'.
           wa_cat-tabname = 'zyogstudent'.
           wa_cat-outputlen = 25.
           wa_cat-seltext_m = 'ZFEES'.
           wa_cat-just = 'C'.
           append wa_cat to field_cat.
           wa_cat-fieldname = 'ZADD'.
           wa_cat-tabname = 'zyogstudent'.
           wa_cat-outputlen = 25.
           wa_cat-seltext_m = 'ZADD'.
           wa_cat-just = 'R'.
           append wa_cat to field_cat.
    endform.                    " field_init
    *&      Form  display
          text
    -->  p1        text
    <--  p2        text
    form display .
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
       I_CALLBACK_PROGRAM                = 'sy-repid'
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
      I_CALLBACK_TOP_OF_PAGE            = ' '
      I_STRUCTURE_NAME                  = itab
       I_GRID_TITLE                      = 'This is grid title'
       IS_LAYOUT                         = xlayout
       IT_FIELDCAT                       = FIELD_CAT
       IT_SORT                           = i_sort
       I_DEFAULT                         = 'X'
      I_SAVE                            = ' '
      IT_EVENTS                         =
      TABLES
        t_outtab                          = itab.
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    endform.                    " display

  • Internal table in pdf output

    Hi All,
    My requirement is on click of a button i need to opwn a new window and display the table output through pdf.
    I am displaying a table through my bsp page using html code.
    On click of a button i need to open a window and show up the table data in pdf which should be printable.
    Am not using any iterator for my table. i just need transfer the internal table output to pdf and display.
    Please help.
    Thanks,
    Sandeep.

    Hi Alonso,
    Am not able to get the solution for my requirement, could you please give me the detailed solution.
    Can i go in this way.
    What parameters should i use for otf FM
    //...convert otf FM
    CONCATENATE cl_abap_char_utilities=>byte_order_mark_little
                    l_xstring
               INTO l_xstring IN BYTE MODE.
        CONCATENATE 'attachment; filename=NIM2_matter_Summary_'
                    sy-uzeit
                    '.pdf'
               INTO l_content.
        CALL METHOD cl_bsp_utility=>download
           EXPORTING
               object_s            = l_xstring
               content_type        = app_type
               content_disposition = l_content
               response            = _m_response
               navigation          = _m_navigation.
    Thanks in advance.

  • Retrieving data into internal table

    Hi,
         I am struck at a point where i have to retrieve data from 4 database table to a single internal table with some conditions. can anyone please help me in resolving this issue. your help will be highly appreciated.
    some details are: tables used are-linv,mch1,makt,ausp.
    data:  begin of t_outtab,--final internal table.---output to be displayed
          lgnum  LIKE linv-lgnum,
          ivnum  LIKE linv-ivnum,
          werks  LIKE linv-werks,
          lgtyp  LIKE linv-lgtyp,
          matnr  LIKE linv-matnr,
          bestq  LIKE linv-bestq,
          charg  LIKE linv-charg,
          maktx  LIKE makt-maktx,
          vfdat  LIKE mch1-vfdat,
          atwrt  LIKE ausp-atwrt,
          END OF t_outtab.
    input parameters:-- linv-lgnum and linv-ivnum.
    conditions:1. Where MAKT-MATNR = LINV-MATNR and MAKT-SPRAS = ‘logon language user’
    2. Where MCH1-CHARG = LINV-CHARG AND MCH1-MATNR = LINV-MATNR)
    3. SELECT AUSP-ATWRT Where AUSP-OBJEK = MCH1- CUOBJ_BM and MCH1-CHARG = LINV-CHARG AND MCH1-MATNR = LINV-MATNR
    Regards
    Victor

    Hi Victor,
    data: begin of t_outtab,--final internal table.---output to be displayed
    lgnum LIKE linv-lgnum,
    ivnum LIKE linv-ivnum,
    werks LIKE linv-werks,
    lgtyp LIKE linv-lgtyp,
    matnr LIKE linv-matnr,
    bestq LIKE linv-bestq,
    charg LIKE linv-charg,
    maktx LIKE makt-maktx,
    vfdat LIKE mch1-vfdat,
    atwrt LIKE ausp-atwrt,
    END OF t_outtab.
    <b>SELECT</b> 
    linv~lgnum,
    linv~ivnum,
    linv~werks,
    linv~lgtyp,
    linv~matnr,
    linv~bestq,
    linv~charg,
    makt~maktx,
    mch1~vfdat,
    ausp~atwrt,
    <b>FROM  ( ( ( LINV JOIN MAKT ) ON</b>  
      MAKTMATNR = LINVMATNR
       <b> INNER JOIN MCH1 )  ON</b> 
    MCH1CHARG = LINVCHARG AND
      MCH1MATNR = LINVMATNR
    <b> INNER JOIN AUSP ) ON</b>
    AUSPOBJEK = MCH1 CUOBJ_BM
    MCH1CHARG = LINVCHARG
    MCH1MATNR = LINVMATNR
    <b>where MAKT-SPRAS = ‘logon language user’.</b>

  • Regarding Passing two internal Tables from Driver Program to Smartform

    hi all,
              I am Passing Two Internal Tables from Driver Program to Smartform it is going to dump and message is showing like this " one of the parameters eded according to the interface description was not specified ".
              When i am passing one Internal Table Output is coming Perfectly. Is there any restriction for passing of internal tables.
    Regards
    Rami

    HI,
    Check the names specified in the smartfrom and FM whcih you are calling in the driver program. Both might be different....

  • Search in internal table utility

    Hi Experts,
    As per my requirement we need a utlity i.e a  class or F.M  which search for a "Word" or "Phrase" in fields of internal table and display the internal table output  based on there ranking.
    For example:
    Search term in internal table is:          Novartis  Global  
    My Internal table has records like this:
    ITAB
    FIELD1                                FIELD2                                   FIELD3                  LINE
    Novartis Global                   xyz                                        Global                    1
    ABC                                  Novartis                                   DXY                       2
    Novartis Global                Novartis Global                        Novartis Global       3
    1020                                  EWR                                       Globaling                 4
    My O/p should be
    FIELD1                                FIELD2                                   FIELD3                    LINE
    Novartis Global                Novartis Global                        Novartis Global         3
    Novartis Global                   xyz                                        Global                       1
    ABC                                  Novartis                                   DXY                          2
    1020                                  EWR                                      Globaling                     4
    For achieving this i used command
    FIND ALL OCCURRENCES OF Novartis  Global     IN TABLE ITAB  RESULTS IT_RESULTS  IN CHARACTER MODE .
    Since all records in my internal table have the search term already it retunrs all the records but i want to RANK these records
    based on my search term
    1.Records which exactly match the keyword in all fields should be first
    2.Records which have the key word in atleast 1 field should be second
    3.Records which have one word of 2 should be third
    and so on RANKING BASED on search term.
    Please suggest how should i go about it ? I am not sure what kind of logic is required here.
    Any suggestions will be appreciated.
    Thanks
    Bhanu

    TYPES: BEGIN OF ty_data,
            f1 TYPE char30,
            f2 TYPE char30,
            f3 TYPE char30,
            line TYPE i,
           END OF ty_data.
    DATA:
    lt_data TYPE TABLE OF ty_data,
    wa_data TYPE ty_data,
    mcnt TYPE i,
    moff TYPE i,
    mlen TYPE i,
    lv_f1 TYPE i,
    lv_f2 TYPE i,
    lv_f3 TYPE i.
    LOOP AT lt_data INTO wa_data.
      lv_f1 = 0.
      lv_f2 = 0.
      lv_f3 = 0.
      FIND ALL OCCURRENCES OF wa_phrase IN wa_data-f1 IN CHARACTER MODE
      RESPECTING CASE MATCH COUNT  mcnt
      MATCH OFFSET moff
      MATCH LENGTH mlen.
      IF sy-subrc = 0.
        lv_f1 = 1.
      ENDIF.
      FIND ALL OCCURRENCES OF wa_phrase IN wa_data-f2 IN CHARACTER MODE
      RESPECTING CASE MATCH COUNT  mcnt
      MATCH OFFSET moff
      MATCH LENGTH mlen.
      IF sy-subrc = 0.
        lv_f2 = 1.
      ENDIF.
      FIND ALL OCCURRENCES OF wa_phrase IN wa_data-f3 IN CHARACTER MODE
      RESPECTING CASE MATCH COUNT  mcnt
      MATCH OFFSET moff
      MATCH LENGTH mlen.
      IF sy-subrc = 0.
        lv_f3 = 1.
      ENDIF.
      lv_f1 = lv_f1 + lv_f2 + lv_f3.
      IF lv_f1 = 3.
        wa_data-line = 1.
      ELSEIF lv_f1 > 0.
        wa_data-line = 2.
      ELSE.
        wa_data-line = 3.
      ENDIF.
      MODIFY lt_data FROM wa_data TRANSPORTING line.
    ENDLOOP.
    SORT lt_data BY line.
    LOOP AT lt_data INTO wa_data.
      WRITE:/ wa_data-f1, wa_data-f2, wa_data-f3, wa_data-line.
    ENDLOOP.
    CLEAR wa_data.
    Hi,
    The above code will sort the table for 1st and 2nd Rank properly. There is still logic to be added for 3rd Rank. The phrase should be split in words and then each word should be searched in each field of internal table and thus derive if its for 3rd Rank or not.
    Thanks,
    Murtuza

  • Downloading internal table.

    hi all,
    i need to down load an internal table to text file.
    i used fm upload ok its working fine.
    my text file is like this
    (line)
                                            abc company
    (line) 
                                      the following are the details
    here internal table data will come.
    i can display the internal table output in file,but i need code how to display that
    line,abc company ,the following are the details in text file.
    can any body provide some sample code for this.
    thanks in advance
    siva

    thanks for ur response.
    i will down load the data to text file from internal table using function module gui down load
    in text file on the top of it i need text like this
                              abc company
    itab-f1        itab-f2      itab-f3      itab-f4       itab-f5
    i want the text abc company on the top of my text file ,i can down load itab-f1,f2,f3 into text file,i am able to do that.how can i down load the text abc company to text file.
    thanks in advance
    siva

  • Unable to Capture ALV output in an Internal Table, after CALL TRANSACTION

    Dear all,
    My requirement is to run multiple materials in T-code CK86_99 but as we know CK86_99 is only adequate to one material at a time.
    So, I want to capture the Output of the T-code in my Internal table with respect to all the Material Numbers I use in the Select-Options of my Z Program.
    Below is the Code I developed so far, but the Class
    cl_salv_bs_runtime_info=>get_data_ref(
            IMPORTING r_data = lf_ref ).
    is not capturing the Ouput...
    Please have a look and enlighten me how it could be solved.
    TABLES : mara.
    DATA : BEGIN OF wa_mara,
      matnr TYPE mara-matnr,
      END OF wa_mara.
    DATA: it_bdcdata TYPE TABLE OF bdcdata,
          wa_it_bdcdata LIKE LINE OF it_bdcdata,
          it_mara LIKE TABLE OF wa_mara.
    *      BELNR(10).
    FIELD-SYMBOLS:<fs_tab> TYPE ANY TABLE,
    <fs_line> TYPE any.
    DATA:lf_ref TYPE REF TO data,
         lf_ref1 TYPE REF TO data.
    SELECT-OPTIONS so_matnr FOR mara-matnr.
    PARAMETERS p_werks LIKE t001w-werks.
    *BELNR = 'Z92'. " Give Document Number here
    SELECT matnr FROM mara INTO TABLE it_mara WHERE matnr IN so_matnr.
    DATA opt TYPE ctu_params.
    LOOP AT it_mara INTO wa_mara.
      CLEAR wa_it_bdcdata.
    wa_it_bdcdata-program  = 'SAPMKKB0'.
    wa_it_bdcdata-dynpro   = '0300'.
    wa_it_bdcdata-dynbegin = 'X'.
      APPEND wa_it_bdcdata TO it_bdcdata.
      CLEAR wa_it_bdcdata.
    wa_it_bdcdata-fnam = 'BDC_CURSOR'.
    wa_it_bdcdata-fval = 'KKB0-MATNR'.
      APPEND wa_it_bdcdata TO it_bdcdata.
      CLEAR wa_it_bdcdata.
    wa_it_bdcdata-fnam = 'KKB0-MATNR'.
      wa_it_bdcdata-fval = wa_mara-matnr.
      APPEND wa_it_bdcdata TO it_bdcdata.
      CLEAR wa_it_bdcdata.
    wa_it_bdcdata-fnam = 'BDC_CURSOR'.
    wa_it_bdcdata-fval = 'KKB0-WERKS'.
      APPEND wa_it_bdcdata TO it_bdcdata.
      CLEAR wa_it_bdcdata.
      wa_it_bdcdata-fnam = 'KKB0-WERKS'.
    wa_it_bdcdata-fval = p_werks.
      APPEND wa_it_bdcdata TO it_bdcdata.
      CLEAR wa_it_bdcdata.
    wa_it_bdcdata-fnam = 'BDC_OKCODE'.
    wa_it_bdcdata-fval = 'OSNY'."'ONLI'."=CRET'.
      APPEND wa_it_bdcdata TO it_bdcdata.
    *  CLEAR wa_it_bdcdata.
    * wa_it_bdcdata-program  = 'SAPLKKRSOO'.
    * wa_it_bdcdata-dynpro   = '0100'.
    * wa_it_bdcdata-dynbegin = 'X'.
    *  APPEND wa_it_bdcdata TO it_bdcdata.
    *  CLEAR wa_it_bdcdata.
    * wa_it_bdcdata-fnam = 'BDC_OKCODE'.
    *  wa_it_bdcdata-fval = 'BACK'."=CRET'.
    *  APPEND wa_it_bdcdata TO it_bdcdata.
    *  CLEAR wa_it_bdcdata.
    * wa_it_bdcdata-program  = 'SAPMKKB0'.
    * wa_it_bdcdata-dynpro   = '0300'.
    * wa_it_bdcdata-dynbegin = 'X'.
    *  APPEND wa_it_bdcdata TO it_bdcdata.
    *  CLEAR wa_it_bdcdata.
    * wa_it_bdcdata-fnam = 'BDC_OKCODE'.
    * wa_it_bdcdata-fval = 'EXIT'."=CRET'.
    *  APPEND wa_it_bdcdata TO it_bdcdata.
      opt-dismode = 'N'.
    cl_salv_bs_runtime_info=>set(
        EXPORTING display  = abap_false
                  metadata = abap_true
    data     = abap_true ).
      CALL TRANSACTION 'CK86_99' USING it_bdcdata OPTIONS FROM opt.
      TRY.
    cl_salv_bs_runtime_info=>get_data_ref(
            IMPORTING r_data = lf_ref ).
          ASSIGN lf_ref->* TO <fs_tab>.
        CATCH cx_salv_bs_sc_runtime_info.
          MESSAGE 'Unable to retrieve ALV data' TYPE 'E'.
      ENDTRY.
    cl_salv_bs_runtime_info=>clear_all( ).
      IF <fs_tab> IS ASSIGNED.
        CREATE DATA lf_ref1 LIKE LINE OF <fs_tab>.
        ASSIGN lf_ref1->* TO <fs_line>.
      ENDIF.
    *LOOP AT <FS_TAB> ASSIGNING <FS_LINE>.
    *ENDLOOP.

    Hi Abhay,
          If you go to Transaction code SE93, enter the tcode "CK86_99" and click display, you may see the default value for transaction is "KKBB" and the screen field for P_SCREEN = 0300, P_TCODE = ck86_99.
          You may need to copy the transaction code "KKBB" and go to SE93 again, enter the tcode for "KKBB" then click display, now you may see the program name is "RKKB1000".
          Hope this answer your question.
    Thanks
    Hock Lin

  • Internal table in Excel output with Header and Total

    Hi All,
    I have a selection-screen of a report where there is option to specify the path of a file to be stored in local PC. This Report gives output in ALV format which displays header and total of columns.
    Now, the requirement is, when the user specifies a path for the file in selection screen it should download in the specified location with header and total row into an excel format.
    The issue is, I have the internal table with data without total and header row and the total is getting displayed in the screen through ALV feature. I am not sure, how to give the same output in downloaded excel with header row and total as it is displayed on screen.
    Please let me know, if you have any suggestions.
    Thanks & Regards,
    Anshumita.

    try using TOP OF PAGE event and write the number of records in the header part.
    hope this will help.

  • Save report painter output into internal table

    Hi,
      i have created a report painter for vendor aging report. got output in drill down format.
    i need to show the data in smartform as well. so need to save the report painter output into an internal table. can anyone please help me resolving this.
    regards,
    sudha.m

    Hi Sudha
    You can use sample below:
    DATA: list_tab TYPE TABLE OF ABAPLIST.
    SUBMIT NROWS EXPORTING LIST TO MEMORY
                  AND RETURN VIA SELECTION-SCREEN.
    CALL FUNCTION 'LIST_FROM_MEMORY'
      TABLES
        listobject = list_tab
      EXCEPTIONS
        not_found  = 1
        OTHERS     = 2.
    IF sy-subrc = 0.
      CALL FUNCTION 'WRITE_LIST'
        TABLES
          listobject = list_tab.
    ENDIF.
    Best regards

  • Report output from memory to internal table (corresponding fields)

    How can we pick any standard report output such as
    RM07DOCS on to memory and from memory to an internal
    table.Here by internal table ,i do not mean of type c
    containing complete report but data should go from output to corresponding fields of internal table structure of whom is defined as same of the output.

    SUBMIT rfbila00 AND RETURN
         EXPORTING LIST TO MEMORY
        WITH sd_ktopl-low = ' '
         WITH sd_bukrs IN  s_bukrs
         WITH sd_prctr IN s_prctr
         WITH bilavers =  p_fsv
         WITH bilaspra =  'EN'
         WITH bilbjahr =   p_fyear
         WITH b-monate IN s_per
         WITH bilvjahr = v_cfyear
         WITH v-monate = l_per
         WITH bilagvar = P_LAYOUT
         WITH bilagrid = 'X'
         WITH bilabkon = '2'
         WITH bilagkon = '3'
         WITH bilasumm = '0'
         WITH bilavart = '1'
         WITH bilaskal = '3/0'.
      CALL FUNCTION 'LIST_FROM_MEMORY'
        TABLES
          listobject = t_list
        EXCEPTIONS
          not_found  = 1.
      REFRESH t_ascii.
      CALL FUNCTION 'LIST_TO_ASCI'
        TABLES
          listasci           = t_ascii " list converted to ASCII
          listobject         = t_list
        EXCEPTIONS
          empty_list         = 1
          list_index_invalid = 2
          OTHERS             = 3.
    u will get the output in t_list...u have to split as per ur requir......
    this will help u.....
    Reward IF...........
    Regards
    Anbu

  • How to set a selected checkbox in output internal table of oops ALV grid

    Hi All,
    i have a checkbox as first column in my ALV grid output using oops alv, when i select some checkbox, that rows have to be selected and i need to process only selected rows in user command.
    i have given the below code also in fieldcatolg.
    f_fldcat-fieldname = 'checkbox'.
    f_fldcat-tabname ='gi_output'
    f_fldcat-checkbox = 'X'.
    f_fldcat-edit = 'X'.
    but the checkbox is not getting set in internal table when i select some checkboxes.
    can anybody explain y the checkbox in internal table not getting set?
    Thanks,
    Srilakshmi.

    Hi,
    i tried already whatever u said, but still not resolved.Pasted my code below..can u please look into it.
    MODULE pbo OUTPUT.
      PERFORM init_container.
      PERFORM prepare_field_catalog.
      PERFORM prepare_layout.
      PERFORM display_output.
    ENDMODULE.                 " PBO  OUTPUT
    *&      Module  PAI  INPUT
          text
    MODULE pai INPUT.
       DATA: lt_rows TYPE lvc_t_row.
      CASE gv_okcode.
        WHEN gc_exit OR gc_back OR gc_canc. " Finish program
          LEAVE PROGRAM.
          when 'PRINT'.
           CALL METHOD gv_grid->get_selected_rows
                     IMPORTING et_index_rows = lt_rows.
            CALL METHOD cl_gui_cfw=>flush.
      ENDCASE.
    ENDMODULE.                 " PAI  INPUT
    *&      Form  INIT_CONTAINER
          text
    FORM init_container .
      CREATE OBJECT gv_custom_container
        EXPORTING
          container_name = gc_container.
      CREATE OBJECT gv_grid
        EXPORTING
          i_parent = gv_custom_container.
      CREATE OBJECT gv_document
        EXPORTING
          style = 'ALV_GRID'.
    *&      Form  PREPARE_FIELD_CATALOG
          text
    FORM prepare_field_catalog .
      PERFORM fill_catalog USING:
    'Table Name'   'Field Name' 'NoZero'   'sel-text'
      'GI_OUTPUT'  'CHECKBOX'   ' '           text-013  'X',
      'GI_OUTPUT'  'KUNNR'      'X'           text-003  ' ',
      'GI_OUTPUT'  'NAME1'      ' '           text-004  ' ',
      'GI_OUTPUT'  'BELNR'      'X'           text-005  ' ',
      'GI_OUTPUT'  'BLART'      ' '           text-006  ' ',
      'GI_OUTPUT'  'BUDAT'      ' '           text-007  ' ',
      'GI_OUTPUT'  'BLDAT'      ' '           text-008  ' ',
      'GI_OUTPUT'  'DMBTR'      ' '           text-009  ' ',
      'GI_OUTPUT'  'WAERS'      ' '           text-010  ' '.
    ENDFORM.                    " PREPARE_FIELD_CATALOG
    *&      Form  FILL_CATALOG
          text
    FORM fill_catalog  USING    fv_tabname
                                fv_fldname
                                fv_nozero
                                fv_seltxt
                                fv_checkbox.
      DATA f_fldcat TYPE lvc_s_fcat.
      f_fldcat-fieldname     = fv_fldname.
      f_fldcat-tabname       = fv_tabname.
      f_fldcat-no_zero       = fv_nozero.
      f_fldcat-coltext       = fv_seltxt.
      f_fldcat-checkbox      = fv_checkbox.
      IF fv_checkbox = gc_x.
        f_fldcat-edit = gc_x.
      ENDIF.
      APPEND f_fldcat TO gi_fieldcat.
    ENDFORM.                    " FILL_CATALOG
    *&      Form  PREPARE_LAYOUT
          text
    FORM prepare_layout .
      gs_layout-info_fname = 'COL'.
      gs_layout-cwidth_opt = gc_x.
      gs_layout-zebra      = gc_x.
      gs_layout-no_toolbar = gc_x.
      gs_layout-no_rowmark = '1'.
      gs_layout-sel_mode = 'A'.
    ENDFORM.                    " PREPARE_LAYOUT
    *&      Form  DISPLAY_OUTPUT
          text
    FORM display_output .
      CALL METHOD gv_grid->set_table_for_first_display
        EXPORTING
          is_layout       = gs_layout
        CHANGING
          it_outtab       = gi_output
          it_fieldcatalog = gi_fieldcat.
      CREATE OBJECT event_receiver.
      SET HANDLER event_receiver->handle_user_command FOR gv_grid.
    CALL METHOD cl_gui_control=>set_focus EXPORTING control = gv_grid.
    ENDFORM.                    " DISPLAY_OUTPUT

  • Dynamic creation of variables and alv grid output/internal table

    Dear Experts
    I am stuck in an inventory ageing report which is to be done year wise. the scenario is as follow.
    selection screen i enter the year 2011 or 2010 or 2009.
    the output should show me 2011-2007 or 2010-2007 or 2009-2007. the alv grid should always start from 2007 and end at the year that is entered in the selection screen.
    Now how can i create a dynamic variables to store the values of the corresponding yr and also how can i create a dynamic internal table to store these values.
    Thanks & Regards
    Zamir Parkar

    Hi Zamir,
    if you are new to ABAP you may leave old and buggy techniques behind.
    If you want to create the table dynamically, please do not use l_alv_table_create=>create_dynamic_table because it is limited and always triggers a possibly unwanted database commit.
    You better use RTTS dynamic runtime type services, i.e. check the example for [Creating Flat and Complex Internal Tables Dynamically using RTTI|http://wiki.sdn.sap.com/wiki/display/Snippets/CreatingFlatandComplexInternalTablesDynamicallyusingRTTI].
    As done here, leave all outdated ALV technologies behind and start with CL_SALV_TABLE. It is following the object-oriented approach and does not need a field catalog.
    You will get used to field-symbols that can be compared to the data referenced by a pointer. For dynamic fields, you may build the field names dynamically, i.e.
    DATA:
          lo_structdescr         TYPE REF TO cl_abap_structdescr,
          lo_typedescr           TYPE REF TO cl_abap_typedescr,
          lo_tabledescr          TYPE REF TO cl_abap_tabledescr,
          lr_data                TYPE REF TO data,
          lt_comp_all            TYPE cl_abap_structdescr=>component_table,
          lv_index               TYPE numc2.
        FIELD-SYMBOLS:
          <any>                  TYPE ANY,
          <component>            TYPE LINE OF abap_component_tab,
           <table>                TYPE table.
        DO nnn TIMES.
          lv_index = sy-index.
          lo_typedescr   =  cl_abap_typedescr=>describe_by_name( <name of data element> ).
          APPEND INITIAL LINE TO lt_comp_all ASSIGNING <component>.
          <component>-type ?= lo_typedescr.
          CONCATENATE 'YEARVAL' lc_underscore lv_index INTO <component>-name.
          <component>-as_include  = abap_true.
          CONCATENATE lc_underscore lv_index INTO <component>-suffix.
        ENDDO.
    * create description object for structured type
        lo_structdescr = cl_abap_structdescr=>create( lt_comp_all ).
    *  create table description object for this
        lo_tabledescr = cl_abap_tabledescr=>create(
                        p_line_type  = lo_structdescr
                        p_table_kind = cl_abap_tabledescr=>tablekind_std
                        p_unique     = abap_false ).
    * create data object
        CREATE DATA lr_data TYPE HANDLE lo_tabledescr.
    ASSIGN lr_data->* to <table>.
    This is a fragment. Please adapt to your needs.
    Regards,
    Clemens

  • 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.

Maybe you are looking for