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

using tables ekko,ekpo,ekkn problem with code plz check once

Hi experts

i am able to fetch data from ekko,ekpo and able to append it also but in the output fieldcat i not able to get data from ekkn i checked it with the normal process the data is coming but not transfering to the fieldcat please see to it

Regards

Thanks in advance

TABLES : EKKO,

EKPO,

EKPV,

EKET,

EKKN.

TYPE-POOLS : SLIS.

DATA : FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,

ILAYOUT TYPE SLIS_LAYOUT_ALV.

DATA : BEGIN OF IT_EKKO OCCURS 0,

EBELN TYPE EKKO-EBELN,

BUKRS TYPE EKKO-BUKRS,

  • AEDAT TYPE EKKO-AEDAT,

ERNAM TYPE EKKO-ERNAM,

LIFNR TYPE EKKO-LIFNR,

ZTERM TYPE EKKO-ZTERM,

EKORG TYPE EKKO-EKORG,

EKGRP TYPE EKKO-EKGRP,

WAERS TYPE EKKO-WAERS,

END OF IT_EKKO.

DATA : BEGIN OF IT_EKPO OCCURS 0,

EBELN TYPE EKPO-EBELN,

MATNR TYPE EKPO-MATNR,

AEDAT TYPE EKPO-AEDAT,

WERKS TYPE EKPO-WERKS,

LGORT TYPE EKPO-LGORT,

MENGE TYPE EKPO-MENGE,

NETPR TYPE EKPO-NETPR,

NETWR TYPE EKPO-NETWR,

MTART TYPE EKPO-MTART,

TXZ01 TYPE EKPO-TXZ01,

END OF IT_EKPO.

DATA : BEGIN OF IT_EKKN OCCURS 0,

EBELN TYPE EKKN-EBELN,

EBELP TYPE EKKN-EBELP,

NETWR TYPE EKKN-NETWR,

MENGE TYPE EKKN-MENGE,

SAKTO TYPE EKKN-SAKTO,

GSBER TYPE EKKN-GSBER,

KOSTL TYPE EKKN-KOSTL,

  • AEDAT TYPE EKKN-AEDAT,

END OF IT_EKKN.

DATA : BEGIN OF IT_DISPLAY OCCURS 0,

EBELN TYPE EKKO-EBELN,

BUKRS TYPE EKKO-BUKRS,

AEDAT TYPE EKKN-AEDAT,

ERNAM TYPE EKKO-ERNAM,

LIFNR TYPE EKKO-LIFNR,

ZTERM TYPE EKKO-ZTERM,

MATNR TYPE EKPO-MATNR,

WERKS TYPE EKPO-WERKS,

LGORT TYPE EKPO-LGORT,

MENGE TYPE EKPO-MENGE,

NETPR TYPE EKPO-NETPR,

NETWR TYPE EKPO-NETWR,

MTART TYPE EKPO-MTART,

TXZ01 TYPE EKPO-TXZ01,

SAKTO TYPE EKKN-SAKTO,

GSBER TYPE EKKN-GSBER,

EKORG TYPE EKKO-EKORG,

  • SAKTO TYPE EKKN-SAKTO,

END OF IT_DISPLAY.

SELECTION-SCREEN : BEGIN OF BLOCK B1.

SELECT-OPTIONS : S_EBELN FOR EKKO-EBELN OBLIGATORY.

SELECT-OPTIONS : S_AEDAT FOR EKKO-AEDAT,

S_MATNR FOR EKPO-MATNR,

S_LGORT FOR EKPO-LGORT.

SELECTION-SCREEN : END OF BLOCK B1.

SELECT EBELN BUKRS AEDAT ERNAM LIFNR ZTERM EKORG FROM EKKO INTO CORRESPONDING FIELDS OF TABLE IT_EKKO

WHERE EBELN IN S_EBELN

AND AEDAT IN S_AEDAT.

IF SY-SUBRC NE 0.

MESSAGE 'PLEASE CHECK THE ENTRY' TYPE 'E'.

EXIT.

ENDIF.

IF SY-SUBRC EQ 0.

SELECT EBELN MATNR WERKS AEDAT LGORT MENGE NETPR NETWR TXZ01 FROM EKPO INTO CORRESPONDING FIELDS OF TABLE IT_EKPO

FOR ALL ENTRIES IN IT_EKKO

WHERE EBELN = IT_EKKO-EBELN

AND MATNR IN S_MATNR.

ENDIF.

LOOP AT IT_EKPO.

SELECT EBELN EBELP NETWR SAKTO GSBER FROM EKKN INTO CORRESPONDING FIELDS OF TABLE IT_EKKN FOR ALL ENTRIES IN IT_EKPO

WHERE EBELN = IT_EKPO-EBELN.

IT_DISPLAY-AEDAT = IT_EKPO-AEDAT.

IT_DISPLAY-ERNAM = IT_EKKO-ERNAM.

IT_DISPLAY-LIFNR = IT_EKKO-LIFNR.

IT_DISPLAY-ZTERM = IT_EKKO-ZTERM.

IT_DISPLAY-EBELN = IT_EKPO-EBELN.

IT_DISPLAY-MATNR = IT_EKPO-MATNR.

IT_DISPLAY-TXZ01 = IT_EKPO-TXZ01.

IT_DISPLAY-WERKS = IT_EKPO-WERKS.

IT_DISPLAY-MENGE = IT_EKPO-MENGE.

IT_DISPLAY-NETPR = IT_EKPO-NETPR.

IT_DISPLAY-NETWR = IT_EKPO-NETWR.

IT_DISPLAY-SAKTO = IT_EKKN-SAKTO.

IT_DISPLAY-GSBER = IT_EKKN-GSBER.

APPEND IT_DISPLAY.

CLEAR IT_DISPLAY.

ENDLOOP.

PERFORM FIELDCAT.

PERFORM DISPLAY_ALV.

FORM FIELDCAT.

REFRESH FIELDCAT.

FIELDCAT-FIELDNAME = 'EBELN'.

FIELDCAT-SELTEXT_M = 'PURCHASE NUMBER'.

APPEND FIELDCAT.

CLEAR FIELDCAT.

FIELDCAT-FIELDNAME = 'AEDAT'.

FIELDCAT-SELTEXT_M = 'DATE'.

APPEND FIELDCAT.

CLEAR FIELDCAT.

FIELDCAT-FIELDNAME = 'MATNR'.

FIELDCAT-SELTEXT_M = 'MATERIAL NO'.

APPEND FIELDCAT.

CLEAR FIELDCAT.

FIELDCAT-FIELDNAME = 'TXZ01'.

FIELDCAT-SELTEXT_M = 'SHORT DOCUMENTATION'.

APPEND FIELDCAT.

CLEAR FIELDCAT.

FIELDCAT-FIELDNAME = 'MENGE'.

FIELDCAT-SELTEXT_M = 'QUANTITY'.

APPEND FIELDCAT.

CLEAR FIELDCAT.

FIELDCAT-FIELDNAME = 'NETPR'.

FIELDCAT-SELTEXT_M = 'PRICE'.

APPEND FIELDCAT.

CLEAR FIELDCAT.

FIELDCAT-FIELDNAME = 'NETWR'.

FIELDCAT-SELTEXT_M = 'NET ORDER VALUE'.

APPEND FIELDCAT.

CLEAR FIELDCAT.

FIELDCAT-FIELDNAME = 'SAKTO'.

FIELDCAT-SELTEXT_M = 'G/L ACCOUNT'.

APPEND FIELDCAT.

CLEAR FIELDCAT.

FIELDCAT-FIELDNAME = 'GSBER'.

FIELDCAT-SELTEXT_M = 'AREA'.

APPEND FIELDCAT.

CLEAR FIELDCAT.

ENDFORM.

FORM DISPLAY_ALV.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = 'SY-CPROG'

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

IS_LAYOUT = ILAYOUT

IT_FIELDCAT = FIELDCAT[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = IT_DISPLAY

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

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 Dec 22, 2008 at 06:29 AM

    Hi,

    Check this....

    FORM FIELDCAT.

    REFRESH FIELDCAT.

    FIELDCAT-FIELDNAME = 'EBELN'.

    FIELDCAT-SELTEXT_M = 'PURCHASE NUMBER'APPEND FIELDCAT.

    .----


    > Here u should enter the Table name and ref table name also...

    FIELDCAT-TABLENAME = 'IT_DISPLAY'

    FIELDCAT-REFTABLENAME = 'EKKO' like this add for all field in fieldcat

    APPEND FIELDCAT.

    CLEAR FIELDCAT.

    FIELDCAT-FIELDNAME = 'AEDAT'.

    FIELDCAT-SELTEXT_M = 'DATE'.

    APPEND FIELDCAT.

    CLEAR FIELDCAT.

    FIELDCAT-FIELDNAME = 'MATNR'.

    FIELDCAT-SELTEXT_M = 'MATERIAL NO'.

    APPEND FIELDCAT.

    CLEAR FIELDCAT.

    FIELDCAT-FIELDNAME = 'TXZ01'.

    FIELDCAT-SELTEXT_M = 'SHORT DOCUMENTATION'.

    APPEND FIELDCAT.

    CLEAR FIELDCAT.

    FIELDCAT-FIELDNAME = 'MENGE'.

    FIELDCAT-SELTEXT_M = 'QUANTITY'.

    APPEND FIELDCAT.

    CLEAR FIELDCAT.

    FIELDCAT-FIELDNAME = 'NETPR'.

    FIELDCAT-SELTEXT_M = 'PRICE'.

    APPEND FIELDCAT.

    CLEAR FIELDCAT.

    FIELDCAT-FIELDNAME = 'NETWR'.

    FIELDCAT-SELTEXT_M = 'NET ORDER VALUE'.

    APPEND FIELDCAT.

    CLEAR FIELDCAT.

    FIELDCAT-FIELDNAME = 'SAKTO'.

    FIELDCAT-SELTEXT_M = 'G/L ACCOUNT'.

    APPEND FIELDCAT.

    CLEAR FIELDCAT.

    FIELDCAT-FIELDNAME = 'GSBER'.

    FIELDCAT-SELTEXT_M = 'AREA'.

    APPEND FIELDCAT.

    CLEAR FIELDCAT.

    ENDFORM.

    Edited by: Upender Verma on Dec 22, 2008 7:29 AM

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi upender,

      Adding the reftab and tabname field is not solving the problem because if you see the output of my program i am getting entries from all the tables but GL account Field which is of table ekkn,Mainly i am not able to get the out put from only this table EKKN rest all is working perfect more over if u see my program i have already defined IT_DISPLAY = IT_EKPO_EBELN similarly for all the fields plz see why entries are not getting into fieldcat only from one table ekkn might be a sily mistake.

      Regards

      sumeet malhotra

  • author's profile photo Former Member
    Former Member
    Posted on Dec 22, 2008 at 06:22 AM

    try to delete the f.m reuse_alv_grid_display in ur program and regenerate it ...

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 22, 2008 at 06:38 AM

    REPORT ZRA_test.

    tables : ekko,ekpo..

    type-pools slis.

    data: begin of i_tab occurs 0,

    ebeln like ekko-ebeln,

    bukrs like ekko-bukrs,

    aedat like ekko-aedat,

    zterm like ekko-zterm,

    waers like ekko-waers,

    ebelp like ekpo-ebelp,

    TXZ01 like ekpo-txz01,

    menge like ekpo-menge,

    bprme like ekpo-bprme,

    netpr like ekpo-netpr,

    end of i_tab.

    ***Field description for ALV***

    DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,

    gd_tab_group TYPE slis_t_sp_group_alv,

    gd_layout TYPE slis_layout_alv,

    gd_repid LIKE sy-repid.

    DATA: repname LIKE sy-repid.

    DATA: fieldtab TYPE slis_t_fieldcat_alv,

    fieldtab1 TYPE slis_t_fieldcat_alv,

    i_grid_title TYPE lvc_title,

    heading TYPE slis_t_listheader,

    f_events TYPE slis_t_event,

    f1_event TYPE slis_alv_event,

    gs_layout TYPE slis_layout_alv.

    DATA:gt_sort TYPE slis_t_sortinfo_alv.

    DATA:gs_filter TYPE slis_t_filter_alv.

    select-options: s_ebeln for ekko-ebeln.

    select aebeln abukrs aaedat azterm a~waers

    bebelp btxz01 btxz01 bmenge bbprme bnetpr

    into corresponding fields of table i_tab

    from ( ekko as a

    inner join ekpo as b on aebeln = bebeln ).

    perform alv_display.

    &----


    *& Form alv_display

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form alv_display .

    perform build_layout.

    perform build_fieldcatlog.

    PERFORM CALL_ALV.

    endform. " alv_display

    &----


    *& Form build_fieldcatlog

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form build_fieldcatlog .

    data l_fieldcat type slis_fieldcat_alv.

    CLEAR l_fieldcat.

    l_fieldcat-fieldname = 'EBELN'.

    l_fieldcat-outputlen = 10.

    l_fieldcat-tabname = 'i_tab'.

    l_fieldcat-no_out = ' '.

    l_fieldcat-seltext_l = text-010.

    APPEND l_fieldcat TO fieldtab1.

    CLEAR l_fieldcat.

    l_fieldcat-fieldname = 'BUKRS'.

    l_fieldcat-outputlen = 4.

    l_fieldcat-tabname = 'i_tab'.

    l_fieldcat-no_out = ' '.

    l_fieldcat-seltext_l = text-011.

    APPEND l_fieldcat TO fieldtab1.

    CLEAR l_fieldcat.

    l_fieldcat-fieldname = 'AEDAT'.

    l_fieldcat-outputlen = 8.

    l_fieldcat-tabname = 'i_tab'.

    l_fieldcat-no_out = ' '.

    l_fieldcat-seltext_l = text-012.

    APPEND l_fieldcat TO fieldtab1.

    CLEAR l_fieldcat.

    l_fieldcat-fieldname = 'ZTERM'.

    l_fieldcat-outputlen = 4.

    l_fieldcat-tabname = 'i_tab'.

    l_fieldcat-no_out = ' '.

    l_fieldcat-seltext_l = text-013.

    APPEND l_fieldcat TO fieldtab1.

    CLEAR l_fieldcat.

    l_fieldcat-fieldname = 'WAERS'.

    l_fieldcat-outputlen = 5.

    l_fieldcat-tabname = 'i_tab'.

    l_fieldcat-no_out = ' '.

    l_fieldcat-seltext_l = text-014.

    APPEND l_fieldcat TO fieldtab1.

    CLEAR l_fieldcat.

    l_fieldcat-fieldname = 'EBELP'.

    l_fieldcat-outputlen = 5.

    l_fieldcat-tabname = 'i_tab'.

    l_fieldcat-no_out = ' '.

    l_fieldcat-seltext_l = text-015.

    APPEND l_fieldcat TO fieldtab1.

    CLEAR l_fieldcat.

    l_fieldcat-fieldname = 'TXZ01'.

    l_fieldcat-outputlen = 40.

    l_fieldcat-tabname = 'i_tab'.

    l_fieldcat-no_out = ' '.

    l_fieldcat-seltext_l = text-016.

    APPEND l_fieldcat TO fieldtab1.

    CLEAR l_fieldcat.

    l_fieldcat-fieldname = 'MENGE'.

    l_fieldcat-outputlen = 15.

    l_fieldcat-tabname = 'i_tab'.

    l_fieldcat-no_out = ' '.

    l_fieldcat-seltext_l = text-017.

    APPEND l_fieldcat TO fieldtab1.

    CLEAR l_fieldcat.

    l_fieldcat-fieldname = 'BPRME'.

    l_fieldcat-outputlen = 3.

    l_fieldcat-tabname = 'i_tab'.

    l_fieldcat-no_out = ' '.

    l_fieldcat-seltext_l = text-018.

    APPEND l_fieldcat TO fieldtab1.

    CLEAR l_fieldcat.

    l_fieldcat-fieldname = 'NETPR'.

    l_fieldcat-outputlen = 13.

    l_fieldcat-tabname = 'i_tab'.

    l_fieldcat-no_out = ' '.

    l_fieldcat-seltext_l = text-019.

    APPEND l_fieldcat TO fieldtab1.

    endform. " build_fieldcatlog

    &----


    *& Form CALL_ALV

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form CALL_ALV .

    REPNAME = SY-REPID.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    • I_BYPASSING_BUFFER = ' '

    • I_BUFFER_ACTIVE = ' '

    I_CALLBACK_PROGRAM = REPNAME

    • I_CALLBACK_PF_STATUS_SET = ' '

    • I_CALLBACK_USER_COMMAND = ' '

    • I_CALLBACK_TOP_OF_PAGE = ' '

    • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

    • I_CALLBACK_HTML_END_OF_LIST = ' '

    • I_STRUCTURE_NAME =

    • I_BACKGROUND_ID = ' '

    • I_GRID_TITLE =

    • I_GRID_SETTINGS =

    IS_LAYOUT = gd_layout

    IT_FIELDCAT = fieldtab1

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    • IT_SORT =

    • IT_FILTER =

    • IS_SEL_HIDE =

    I_DEFAULT = 'X'

    I_SAVE = ' '

    • IS_VARIANT =

    • IT_EVENTS = f_events

    • IT_EVENT_EXIT =

    • IS_PRINT =

    • IS_REPREP_ID =

    • I_SCREEN_START_COLUMN = 0

    • I_SCREEN_START_LINE = 0

    • I_SCREEN_END_COLUMN = 0

    • I_SCREEN_END_LINE = 0

    • I_HTML_HEIGHT_TOP = 0

    • I_HTML_HEIGHT_END = 0

    • IT_ALV_GRAPHICS =

    • IT_HYPERLINK =

    • IT_ADD_FIELDCAT =

    • IT_EXCEPT_QINFO =

    • IR_SALV_FULLSCREEN_ADAPTER =

    • IMPORTING

    • E_EXIT_CAUSED_BY_CALLER =

    • ES_EXIT_CAUSED_BY_USER =

    TABLES

    t_outtab = i_tab

    EXCEPTIONS

    PROGRAM_ERROR = 1

    OTHERS = 2

    .

    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. " CALL_ALV

    &----


    *& Form build_layout

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form build_layout .

    gd_layout-zebra = 'X'.

    gd_layout-info_fieldname = 'ROWCOLOR'.

    endform. " build_layout

    thanks

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 22, 2008 at 07:48 AM

    Hi Sumeet,

    I have done a slight modification to your program(In the selection of EKKN)

    It is coming now.

    But there are many flaws in your code.

    During selection from EKKN you have to use EBELN and EBELP bothKPo

    
    
    REPORT  ytest_ekkn.
    
    TABLES : ekko,
    ekpo,
    ekpv,
    eket,
    ekkn.
    
    TYPE-POOLS : slis.
    
    DATA : fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
    ilayout TYPE slis_layout_alv.
    
    DATA : BEGIN OF it_ekko OCCURS 0,
    ebeln TYPE ekko-ebeln,
    bukrs TYPE ekko-bukrs,
    
    
    aedat TYPE ekko-aedat,
    ernam TYPE ekko-ernam,
    lifnr TYPE ekko-lifnr,
    zterm TYPE ekko-zterm,
    ekorg TYPE ekko-ekorg,
    ekgrp TYPE ekko-ekgrp,
    waers TYPE ekko-waers,
    END OF it_ekko.
    
    
    DATA : BEGIN OF it_ekpo OCCURS 0,
    ebeln TYPE ekpo-ebeln,
    matnr TYPE ekpo-matnr,
    aedat TYPE ekpo-aedat,
    werks TYPE ekpo-werks,
    lgort TYPE ekpo-lgort,
    menge TYPE ekpo-menge,
    netpr TYPE ekpo-netpr,
    netwr TYPE ekpo-netwr,
    mtart TYPE ekpo-mtart,
    txz01 TYPE ekpo-txz01,
    END OF it_ekpo.
    
    
    
    DATA : BEGIN OF it_ekkn OCCURS 0,
    ebeln TYPE ekkn-ebeln,
    ebelp TYPE ekkn-ebelp,
    netwr TYPE ekkn-netwr,
    menge TYPE ekkn-menge,
    sakto TYPE ekkn-sakto,
    gsber TYPE ekkn-gsber,
    kostl TYPE ekkn-kostl,
    
    
    aedat TYPE ekkn-aedat,
    END OF it_ekkn.
    
    DATA : BEGIN OF it_display OCCURS 0,
    ebeln TYPE ekko-ebeln,
    bukrs TYPE ekko-bukrs,
    aedat TYPE ekkn-aedat,
    ernam TYPE ekko-ernam,
    lifnr TYPE ekko-lifnr,
    zterm TYPE ekko-zterm,
    matnr TYPE ekpo-matnr,
    werks TYPE ekpo-werks,
    lgort TYPE ekpo-lgort,
    menge TYPE ekpo-menge,
    netpr TYPE ekpo-netpr,
    netwr TYPE ekpo-netwr,
    mtart TYPE ekpo-mtart,
    txz01 TYPE ekpo-txz01,
    sakto TYPE ekkn-sakto,
    gsber TYPE ekkn-gsber,
    ekorg TYPE ekko-ekorg,
    *SAKTO TYPE EKKN-SAKTO,
    END OF it_display.
    
    SELECTION-SCREEN : BEGIN OF BLOCK b1.
    
    SELECT-OPTIONS : s_ebeln FOR ekko-ebeln OBLIGATORY.
    
    
    SELECT-OPTIONS : s_aedat FOR ekko-aedat,
    s_matnr FOR ekpo-matnr,
    s_lgort FOR ekpo-lgort.
    
    
    SELECTION-SCREEN : END OF BLOCK b1.
    
    
    
    SELECT ebeln bukrs aedat ernam lifnr zterm ekorg FROM ekko INTO CORRESPONDING FIELDS OF TABLE it_ekko
    WHERE ebeln IN s_ebeln
    AND aedat IN s_aedat.
    
    
    IF sy-subrc NE 0.
    
      MESSAGE 'PLEASE CHECK THE ENTRY' TYPE 'E'.
      EXIT.
    ENDIF.
    
    IF sy-subrc EQ 0.
    
      SELECT ebeln matnr werks aedat lgort menge netpr netwr txz01 FROM ekpo INTO CORRESPONDING FIELDS OF TABLE it_ekpo
      FOR ALL ENTRIES IN it_ekko
      WHERE ebeln = it_ekko-ebeln
      AND matnr IN s_matnr.
    ENDIF.
    
    
    
      SELECT ebeln ebelp netwr sakto gsber FROM ekkn
      INTO CORRESPONDING FIELDS OF TABLE it_ekkn FOR ALL ENTRIES IN it_ekpo
      WHERE ebeln = it_ekpo-ebeln.
    
    LOOP AT it_ekpo.
    read table it_ekkn with key ebeln = it_ekpo-ebeln.
    *                            ebelp = it_ekpo-ebelp.
    
      it_display-aedat = it_ekpo-aedat.
      it_display-ernam = it_ekko-ernam.
      it_display-lifnr = it_ekko-lifnr.
      it_display-zterm = it_ekko-zterm.
      it_display-ebeln = it_ekpo-ebeln.
      it_display-matnr = it_ekpo-matnr.
      it_display-txz01 = it_ekpo-txz01.
      it_display-werks = it_ekpo-werks.
      it_display-menge = it_ekpo-menge.
      it_display-netpr = it_ekpo-netpr.
      it_display-netwr = it_ekpo-netwr.
      it_display-sakto = it_ekkn-sakto.
      it_display-gsber = it_ekkn-gsber.
    
    
      APPEND it_display.
    
      CLEAR it_display.
    ENDLOOP.
    
    
    PERFORM fieldcat.
    
    PERFORM display_alv.
    
    
    *&---------------------------------------------------------------------*
    *&      Form  FIELDCAT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    FORM fieldcat.
      REFRESH fieldcat.
    
      fieldcat-fieldname = 'EBELN'.
      fieldcat-seltext_m = 'PURCHASE NUMBER'.
      APPEND fieldcat.
      CLEAR fieldcat.
    
      fieldcat-fieldname = 'AEDAT'.
      fieldcat-seltext_m = 'DATE'.
      APPEND fieldcat.
      CLEAR fieldcat.
    
      fieldcat-fieldname = 'MATNR'.
      fieldcat-seltext_m = 'MATERIAL NO'.
      APPEND fieldcat.
      CLEAR fieldcat.
    
    
      fieldcat-fieldname = 'TXZ01'.
      fieldcat-seltext_m = 'SHORT DOCUMENTATION'.
      APPEND fieldcat.
      CLEAR fieldcat.
    
      fieldcat-fieldname = 'MENGE'.
      fieldcat-seltext_m = 'QUANTITY'.
      APPEND fieldcat.
      CLEAR fieldcat.
    
    
      fieldcat-fieldname = 'NETPR'.
      fieldcat-seltext_m = 'PRICE'.
      APPEND fieldcat.
      CLEAR fieldcat.
    
      fieldcat-fieldname = 'NETWR'.
      fieldcat-seltext_m = 'NET ORDER VALUE'.
      APPEND fieldcat.
      CLEAR fieldcat.
    
      fieldcat-fieldname = 'SAKTO'.
      fieldcat-seltext_m = 'G/L ACCOUNT'.
      APPEND fieldcat.
      CLEAR fieldcat.
    
      fieldcat-fieldname = 'GSBER'.
      fieldcat-seltext_m = 'AREA'.
      APPEND fieldcat.
      CLEAR fieldcat.
    ENDFORM.                    "FIELDCAT
    
    
    
    
    *&---------------------------------------------------------------------*
    *&      Form  DISPLAY_ALV
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    FORM display_alv.
    
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
    *I_INTERFACE_CHECK = ' '
    *I_BYPASSING_BUFFER = ' '
    *I_BUFFER_ACTIVE = ' '
      i_callback_program = 'SY-CPROG'
    
    *I_CALLBACK_PF_STATUS_SET = ' '
    *I_CALLBACK_USER_COMMAND = ' '
    *I_CALLBACK_TOP_OF_PAGE = ' '
    *I_CALLBACK_HTML_TOP_OF_PAGE = ' '
    *I_CALLBACK_HTML_END_OF_LIST = ' '
    *I_STRUCTURE_NAME =
    *I_BACKGROUND_ID = ' '
    *I_GRID_TITLE =
    *I_GRID_SETTINGS =
      is_layout = ilayout
      it_fieldcat = fieldcat[]
    *
    *IT_EXCLUDING =
    *IT_SPECIAL_GROUPS =
    *IT_SORT =
    *IT_FILTER =
    *IS_SEL_HIDE =
      i_default = 'X'
    *I_SAVE = ' '
    *IS_VARIANT =
    *IT_EVENTS =
    *IT_EVENT_EXIT =
    *IS_PRINT =
    *IS_REPREP_ID =
    *I_SCREEN_START_COLUMN = 0
    *I_SCREEN_START_LINE = 0
    *I_SCREEN_END_COLUMN = 0
    *I_SCREEN_END_LINE = 0
    *I_HTML_HEIGHT_TOP = 0
    *I_HTML_HEIGHT_END = 0
    *IT_ALV_GRAPHICS =
    *IT_HYPERLINK =
    *IT_ADD_FIELDCAT =
    *IT_EXCEPT_QINFO =
    *IR_SALV_FULLSCREEN_ADAPTER =
    *IMPORTING
    *E_EXIT_CAUSED_BY_CALLER =
    *ES_EXIT_CAUSED_BY_USER =
      TABLES
      t_outtab = it_display
    
      EXCEPTIONS
      program_error = 1
      OTHERS = 2
      .
      IF sy-subrc ne 0.
    
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    "DISPLAY_ALV
    
    

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 22, 2008 at 07:50 AM

    Hi Sumeet,

    I have done a slight modification to your program(In the selection of EKKN)

    It is coming now.

    But there are many flaws in your code.

    During selection from EKKN you have to use EBELN and EBELP both from EKPO.

    and you have written select inside Loop.

    
    
    REPORT  ytest_ekkn.
    
    TABLES : ekko,
    ekpo,
    ekpv,
    eket,
    ekkn.
    
    TYPE-POOLS : slis.
    
    DATA : fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
    ilayout TYPE slis_layout_alv.
    
    DATA : BEGIN OF it_ekko OCCURS 0,
    ebeln TYPE ekko-ebeln,
    bukrs TYPE ekko-bukrs,
    
    
    aedat TYPE ekko-aedat,
    ernam TYPE ekko-ernam,
    lifnr TYPE ekko-lifnr,
    zterm TYPE ekko-zterm,
    ekorg TYPE ekko-ekorg,
    ekgrp TYPE ekko-ekgrp,
    waers TYPE ekko-waers,
    END OF it_ekko.
    
    
    DATA : BEGIN OF it_ekpo OCCURS 0,
    ebeln TYPE ekpo-ebeln,
    matnr TYPE ekpo-matnr,
    aedat TYPE ekpo-aedat,
    werks TYPE ekpo-werks,
    lgort TYPE ekpo-lgort,
    menge TYPE ekpo-menge,
    netpr TYPE ekpo-netpr,
    netwr TYPE ekpo-netwr,
    mtart TYPE ekpo-mtart,
    txz01 TYPE ekpo-txz01,
    END OF it_ekpo.
    
    
    
    DATA : BEGIN OF it_ekkn OCCURS 0,
    ebeln TYPE ekkn-ebeln,
    ebelp TYPE ekkn-ebelp,
    netwr TYPE ekkn-netwr,
    menge TYPE ekkn-menge,
    sakto TYPE ekkn-sakto,
    gsber TYPE ekkn-gsber,
    kostl TYPE ekkn-kostl,
    
    
    aedat TYPE ekkn-aedat,
    END OF it_ekkn.
    
    DATA : BEGIN OF it_display OCCURS 0,
    ebeln TYPE ekko-ebeln,
    bukrs TYPE ekko-bukrs,
    aedat TYPE ekkn-aedat,
    ernam TYPE ekko-ernam,
    lifnr TYPE ekko-lifnr,
    zterm TYPE ekko-zterm,
    matnr TYPE ekpo-matnr,
    werks TYPE ekpo-werks,
    lgort TYPE ekpo-lgort,
    menge TYPE ekpo-menge,
    netpr TYPE ekpo-netpr,
    netwr TYPE ekpo-netwr,
    mtart TYPE ekpo-mtart,
    txz01 TYPE ekpo-txz01,
    sakto TYPE ekkn-sakto,
    gsber TYPE ekkn-gsber,
    ekorg TYPE ekko-ekorg,
    *SAKTO TYPE EKKN-SAKTO,
    END OF it_display.
    
    SELECTION-SCREEN : BEGIN OF BLOCK b1.
    
    SELECT-OPTIONS : s_ebeln FOR ekko-ebeln OBLIGATORY.
    
    
    SELECT-OPTIONS : s_aedat FOR ekko-aedat,
    s_matnr FOR ekpo-matnr,
    s_lgort FOR ekpo-lgort.
    
    
    SELECTION-SCREEN : END OF BLOCK b1.
    
    
    
    SELECT ebeln bukrs aedat ernam lifnr zterm ekorg FROM ekko INTO CORRESPONDING FIELDS OF TABLE it_ekko
    WHERE ebeln IN s_ebeln
    AND aedat IN s_aedat.
    
    
    IF sy-subrc NE 0.
    
      MESSAGE 'PLEASE CHECK THE ENTRY' TYPE 'E'.
      EXIT.
    ENDIF.
    
    IF sy-subrc EQ 0.
    
      SELECT ebeln matnr werks aedat lgort menge netpr netwr txz01 FROM ekpo INTO CORRESPONDING FIELDS OF TABLE it_ekpo
      FOR ALL ENTRIES IN it_ekko
      WHERE ebeln = it_ekko-ebeln
      AND matnr IN s_matnr.
    ENDIF.
    
    
    
      SELECT ebeln ebelp netwr sakto gsber FROM ekkn
      INTO CORRESPONDING FIELDS OF TABLE it_ekkn FOR ALL ENTRIES IN it_ekpo
      WHERE ebeln = it_ekpo-ebeln.
    
    LOOP AT it_ekpo.
    read table it_ekkn with key ebeln = it_ekpo-ebeln.
    *                            ebelp = it_ekpo-ebelp.
    
      it_display-aedat = it_ekpo-aedat.
      it_display-ernam = it_ekko-ernam.
      it_display-lifnr = it_ekko-lifnr.
      it_display-zterm = it_ekko-zterm.
      it_display-ebeln = it_ekpo-ebeln.
      it_display-matnr = it_ekpo-matnr.
      it_display-txz01 = it_ekpo-txz01.
      it_display-werks = it_ekpo-werks.
      it_display-menge = it_ekpo-menge.
      it_display-netpr = it_ekpo-netpr.
      it_display-netwr = it_ekpo-netwr.
      it_display-sakto = it_ekkn-sakto.
      it_display-gsber = it_ekkn-gsber.
    
    
      APPEND it_display.
    
      CLEAR it_display.
    ENDLOOP.
    
    
    PERFORM fieldcat.
    
    PERFORM display_alv.
    
    
    *&---------------------------------------------------------------------*
    *&      Form  FIELDCAT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    FORM fieldcat.
      REFRESH fieldcat.
    
      fieldcat-fieldname = 'EBELN'.
      fieldcat-seltext_m = 'PURCHASE NUMBER'.
      APPEND fieldcat.
      CLEAR fieldcat.
    
      fieldcat-fieldname = 'AEDAT'.
      fieldcat-seltext_m = 'DATE'.
      APPEND fieldcat.
      CLEAR fieldcat.
    
      fieldcat-fieldname = 'MATNR'.
      fieldcat-seltext_m = 'MATERIAL NO'.
      APPEND fieldcat.
      CLEAR fieldcat.
    
    
      fieldcat-fieldname = 'TXZ01'.
      fieldcat-seltext_m = 'SHORT DOCUMENTATION'.
      APPEND fieldcat.
      CLEAR fieldcat.
    
      fieldcat-fieldname = 'MENGE'.
      fieldcat-seltext_m = 'QUANTITY'.
      APPEND fieldcat.
      CLEAR fieldcat.
    
    
      fieldcat-fieldname = 'NETPR'.
      fieldcat-seltext_m = 'PRICE'.
      APPEND fieldcat.
      CLEAR fieldcat.
    
      fieldcat-fieldname = 'NETWR'.
      fieldcat-seltext_m = 'NET ORDER VALUE'.
      APPEND fieldcat.
      CLEAR fieldcat.
    
      fieldcat-fieldname = 'SAKTO'.
      fieldcat-seltext_m = 'G/L ACCOUNT'.
      APPEND fieldcat.
      CLEAR fieldcat.
    
      fieldcat-fieldname = 'GSBER'.
      fieldcat-seltext_m = 'AREA'.
      APPEND fieldcat.
      CLEAR fieldcat.
    ENDFORM.                    "FIELDCAT
    
    
    
    
    *&---------------------------------------------------------------------*
    *&      Form  DISPLAY_ALV
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    FORM display_alv.
    
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
    *I_INTERFACE_CHECK = ' '
    *I_BYPASSING_BUFFER = ' '
    *I_BUFFER_ACTIVE = ' '
      i_callback_program = 'SY-CPROG'
    
    *I_CALLBACK_PF_STATUS_SET = ' '
    *I_CALLBACK_USER_COMMAND = ' '
    *I_CALLBACK_TOP_OF_PAGE = ' '
    *I_CALLBACK_HTML_TOP_OF_PAGE = ' '
    *I_CALLBACK_HTML_END_OF_LIST = ' '
    *I_STRUCTURE_NAME =
    *I_BACKGROUND_ID = ' '
    *I_GRID_TITLE =
    *I_GRID_SETTINGS =
      is_layout = ilayout
      it_fieldcat = fieldcat[]
    *
    *IT_EXCLUDING =
    *IT_SPECIAL_GROUPS =
    *IT_SORT =
    *IT_FILTER =
    *IS_SEL_HIDE =
      i_default = 'X'
    *I_SAVE = ' '
    *IS_VARIANT =
    *IT_EVENTS =
    *IT_EVENT_EXIT =
    *IS_PRINT =
    *IS_REPREP_ID =
    *I_SCREEN_START_COLUMN = 0
    *I_SCREEN_START_LINE = 0
    *I_SCREEN_END_COLUMN = 0
    *I_SCREEN_END_LINE = 0
    *I_HTML_HEIGHT_TOP = 0
    *I_HTML_HEIGHT_END = 0
    *IT_ALV_GRAPHICS =
    *IT_HYPERLINK =
    *IT_ADD_FIELDCAT =
    *IT_EXCEPT_QINFO =
    *IR_SALV_FULLSCREEN_ADAPTER =
    *IMPORTING
    *E_EXIT_CAUSED_BY_CALLER =
    *ES_EXIT_CAUSED_BY_USER =
      TABLES
      t_outtab = it_display
    
      EXCEPTIONS
      program_error = 1
      OTHERS = 2
      .
      IF sy-subrc ne 0.
    
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    "DISPLAY_ALV
    
    

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 22, 2008 at 08:34 AM

    Hi sandipan

    Thanks for solving my problem i was making a sily mistake thanks you solved my problem.

    Regards

    Sumeet Malhotra

    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.