Skip to Content
author's profile photo Former Member
Former Member

Internal Table

Hi Experts,

i have to display all the fields of internal table to display. Internal table is type of database table(KNA1). How can i do this?

regards,

vipin

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Aug 24, 2007 at 04:48 AM

    Hi,

    Loop at internal table.

    write the field values.

    Endloop.

    Regards,

    Priyanka.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 24, 2007 at 04:50 AM

    Hi,

    loop at i_kna1.
      write :/ i_kna1.
    endloop.
    

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 24, 2007 at 04:52 AM

    Hi Singh,

    After fetching all the values to internal table.

    you can use this.

    loop at itab.

    write:/ itab.

    endloop.

    If you find any problem for this code. Just deselect unicode convertable.

    Reward if useful.

    kishore

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 24, 2007 at 04:52 AM

    Hi,

    Try like this.

    Loop at gi_kna1 into gs_kna1.

    write: /n gs_kna1.

    endloop.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 24, 2007 at 04:54 AM

    1.declare the internal table.

    2.Move the contents from DB table into the internal table based on your condition

    3.write:\ itab.

    <b>see this sample code where a number of internal tables are used</b>

    &----


    *& Report Y_MATERIAL_EXTRACTION_INT *

    &----


    ----


    • PROGRAM DETAILS *

    • Program : Y_MATERIAL_EXTRACTION_INT *

    • Program Title : MATERIAL MASTER EXTRACTION INTERACTIVE REPORT *

    ----


    ----


    • SYSTEM DETAILS

    • Sap Release : EC5

    • Module : Materials Management

    ----


    ----


    • PROGRAM DESCRIPTION : INTERACTIVE REPORT FOR DISPLAYING THE MATERIAL

    • MASTER DETAILS

    ----


    REPORT Y_MATERIAL_EXTRACTION_INT LINE-SIZE 203

    LINE-COUNT 50(5)

    NO STANDARD PAGE HEADING.

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

    • T A B L E S *******************

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

    TABLES: mara, "GENERAL MASTER DATA

    marc, "PLANT DATA FOR MATERIAL

    mard, "STORAGE LOCATION DATA FOR MATERIAL

    mvke, "SALES DATA FOR MATERIAL

    makt. "MATERIAL DESCRIPTION

    DATA: r_labst_total LIKE mard-labst VALUE '0'.

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

    • I N T E R N A L T A B L E S *******************

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

    DATA:BEGIN OF i_marc OCCURS 0,

    matnr LIKE marc-matnr,

    werks LIKE marc-werks,

    dispo LIKE marc-dispo,

    END OF i_marc.

    DATA: BEGIN OF I_MARA OCCURS 0,

    matnr LIKE mara-matnr,

    mbrsh LIKE mara-mbrsh,

    meins LIKE mara-meins,

    matkl LIKE mara-matkl,

    END OF I_MARA.

    DATA:BEGIN OF i_mard OCCURS 0,

    matnr LIKE mard-matnr,

    lgort LIKE mard-lgort,

    labst LIKE mard-labst,

    END OF i_mard.

    DATA: BEGIN OF i_mvke OCCURS 0,

    matnr LIKE mvke-matnr,

    vkorg LIKE mvke-vkorg,

    vtweg LIKE mvke-vtweg,

    END OF i_mvke.

    DATA:BEGIN OF i_makt OCCURS 0,

    matnr LIKE makt-matnr,

    spras LIKE makt-spras,

    maktx LIKE makt-maktx,

    END OF i_makt.

    DATA: BEGIN OF i_out occurs 0,

    matnr LIKE marc-matnr,

    werks LIKE marc-werks,

    dispo LIKE marc-dispo,

    mbrsh LIKE mara-mbrsh,

    meins LIKE mara-meins,

    matkl LIKE mara-matkl,

    vkorg LIKE mvke-vkorg,

    vtweg LIKE mvke-vtweg,

    spras LIKE makt-spras,

    maktx LIKE makt-maktx,

    lgort LIKE mard-lgort,

    labst LIKE mard-labst,

    labst_total LIKE mard-labst,

    END OF i_out.

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

    • S T A R T - O F - S E L EC T I O N *******************

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

    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-100.

    SELECT-OPTIONS: s_matnr FOR marc-matnr OBLIGATORY,

    s_werks FOR marc-werks NO INTERVALS OBLIGATORY,

    s_lgort FOR mard-lgort,

    s_dispo FOR marc-dispo.

    SELECTION-SCREEN END OF BLOCK b1.

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

    • I N I T I A L I Z A T I O N ***********************

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

    INITIALIZATION.

    s_matnr-SIGN = 'I'.

    s_matnr-OPTION = 'EQ'.

    s_matnr-LOW = 'm-14'.

    s_matnr-HIGH = 'm-18'.

    s_werks-SIGN = 'I'.

    s_werks-OPTION = 'EQ'.

    s_werks-LOW = '3000'.

    s_werks-HIGH = '3000'.

    s_lgort-SIGN = 'I'.

    s_lgort-OPTION = 'EQ'.

    s_lgort-LOW = '0001'.

    s_lgort-HIGH = '0007'.

    s_dispo-SIGN = 'I'.

    s_dispo-OPTION = 'EQ'.

    s_dispo-LOW = '001'.

    s_dispo-HIGH = '007'.

    APPEND s_werks.

    APPEND s_dispo.

    APPEND s_lgort.

    APPEND s_matnr.

    CLEAR s_werks.

    CLEAR s_dispo.

    CLEAR s_lgort.

    CLEAR s_matnr.

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

    • S T A R T - O F - S E L EC T I O N *******************

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

    START-OF-SELECTION.

    SELECT matnr werks dispo

    FROM marc

    INTO TABLE i_marc

    WHERE matnr IN s_matnr

    AND werks IN s_werks

    AND dispo IN s_dispo.

    IF i_marc[] IS INITIAL.

    WRITE:/'NO MATCHING DATA IS FOUND FROM TABLE MARC'.

    EXIT.

    ENDIF.

    SELECT matnr lgort labst

    FROM mard

    INTO TABLE i_mard

    FOR ALL ENTRIES IN i_marc

    WHERE matnr = i_marc-matnr

    AND werks IN s_werks

    AND lgort IN s_lgort.

    IF i_mard[] IS INITIAL.

    WRITE:/ 'NO MATCHING DATA IS SELECTED FROM TABLE MARD'.

    EXIT.

    ENDIF.

    SELECT matnr mbrsh meins matkl

    FROM mara

    INTO TABLE i_mara

    FOR ALL ENTRIES IN i_mard

    WHERE matnr = i_mard-matnr.

    SELECT matnr spras maktx

    FROM makt

    INTO TABLE i_makt

    FOR ALL ENTRIES IN i_mara

    WHERE matnr = i_mara-matnr

    AND spras = SY-LANGU.

    SELECT matnr vkorg vtweg

    FROM mvke

    INTO TABLE I_MVKE

    FOR ALL ENTRIES IN i_makt

    WHERE matnr = i_makt-matnr.

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

    • MOVING DATA TO i_out ************************************

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

    LOOP AT i_marc.

    MOVE:i_marc-matnr TO i_out-matnr,

    i_marc-werks TO i_out-werks,

    i_marc-dispo TO i_out-dispo.

    READ TABLE i_mara WITH KEY matnr = i_marc-matnr.

    MOVE: i_mara-mbrsh To i_out-mbrsh,

    i_mara-meins TO i_out-meins,

    i_mara-matkl TO i_out-matkl.

    READ TABLE i_makt WITH KEY matnr = i_marc-matnr.

    MOVE: i_makt-spras TO i_out-spras,

    i_makt-maktx TO i_out-maktx.

    READ TABLE i_mvke WITH KEY matnr = i_marc-matnr.

    MOVE:i_mvke-vkorg TO i_out-vkorg.

    MOVE i_mvke-vtweg TO i_out-vtweg.

    READ TABLE i_mard WITH KEY matnr = i_marc-matnr.

    MOVE: i_mard-lgort TO i_out-lgort,

    i_mard-labst TO i_out-labst.

    APPEND i_out.

    CLEAR i_out.

    ENDLOOP.

    &----


    *& DISPLAYIING FROM I-OUT *

    &----


    LOOP AT i_out.

    AT FIRST.

    WRITE:/ 'Before First Record' COLOR 4.

    WRITE:/ SY-UlINE.

    ENDAT.

    WRITE: SY-VLINE, 5 i_out-matnr,SY-VLINE,

    25 i_out-werks,SY-VLINE,

    31 i_out-dispo,SY-VLINE,

    36 i_out-mbrsh,SY-VLINE,

    40 i_out-meins,SY-VLINE,

    45 i_out-matkl,SY-VLINE,

    60 i_out-vkorg,SY-VLINE,

    70 i_out-vtweg,SY-VLINE,

    80 i_out-maktx,SY-VLINE,

    125 i_out-lgort,SY-VLINE,

    132 i_out-labst,SY-VLINE.

    r_labst_total = r_labst_total + i_out-labst.

    AT NEW matnr.

    WRITE: 'New Material Number' COLOR 5.

    WRITE: SY-VLINE.

    ENDAT.

    AT END OF labst.

    WRITE: 'Stock = ', r_labst_total COLOR 6,

    SY-VLINE.

    WRITE:/ SY-ULINE.

    ENDAT.

    AT LAST.

    SKIP 2.

    WRITE: /50 'Total Stock = ' color 3,r_labst_total COLOR 7.

    ENDAT.

    ENDLOOP.

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

    • E N D - O F - S E L EC T I O N ***********************

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

    END-OF-SELECTION.

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

    • T O P - O F - P A G E ************************

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

    TOP-OF-PAGE.

    WRITE 60 'MATERIAL MASTER REPORT' COLOR COL_GROUP.

    WRITE: SY-ULINE.

    WRITE: /6 'MATERIAL_NO',

    26 'PLANT',

    31 'MRP',

    36 'INDUSTRY',

    40 'BUOM',

    47 'MAT GROUP',

    61 'SALES_ORG',

    70 'DSTR_CHNL',

    82 'DESCRIPTION',

    125 'S_LOC',

    132 'STOCK'.

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

    • E N D - O F - P A G E ************************

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

    END-OF-PAGE.

    WRITE: / SY-ULINE.

    WRITE: /85 'PAGNO: ',SY-PAGNO,

    SY-ULINE.

    regards,

    kaushik

    <b>reward if useful</b>

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 12, 2007 at 07:43 AM

    Hi all

    May i know what the exact solution to vipin s question is ?

    Regards

    Kruthika

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.