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

how to get selected records frommbasic list into an internal table

Hi All,

There is a basic list shown below,

<b>Select Customer Sales organization Distribution Channel Division</b>

and there is a menu option after selecting the records from the basic list, i should run a tr XD06, how i get the selected records into an internal table.

Thanks,

sai

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 02:18 PM

    Hi,

    here below a sample code to help you, you just have to replace selection

    report z_fi_00_0281010 .

    • Type-pool of ALV

    type-pools: slis.

    tables : skb1, bseg.

    parameters : p_bukrs like bseg-bukrs obligatory.

    select-options : s_belnr for bseg-belnr,

    s_gjahr for bseg-gjahr obligatory.

    parameters : p_hkont like bseg-hkont obligatory.

    parameters : p_lokkt like skb1-altkt obligatory.

    data : begin of it_tab occurs 0,

    bukrs like bseg-bukrs,

    belnr like bseg-belnr,

    gjahr like bseg-gjahr,

    buzei like bseg-buzei,

    hkont like bseg-hkont,

    lokkt like bseg-lokkt,

    lokkt2 like bseg-lokkt,

    mark type flag,

    ampel type flag,

    end of it_tab.

    • ALV Data

    data: gt_fieldcat type slis_t_fieldcat_alv,

    gs_layout type slis_layout_alv,

    gs_keyinfo type slis_keyinfo_alv,

    gt_excluding type slis_t_extab,

    gt_sp_group type slis_t_sp_group_alv,

    gt_events type slis_t_event,

    gx_variant like disvariant,

    g_variant like disvariant,

    fieldcat type slis_t_fieldcat_alv.

    data : hrepid like sy-repid,

    htabix like sy-tabix.

    start-of-selection.

    check sy-uname = 'EYNARDL'.

    select single * from skb1 where bukrs = p_bukrs

    and saknr = p_hkont.

    select bukrs belnr gjahr buzei hkont lokkt

    into table it_tab

    from bseg where bukrs eq p_bukrs

    and belnr in s_belnr

    and gjahr in s_gjahr

    and hkont eq p_hkont.

    loop at it_tab.

    it_tab-lokkt2 = p_lokkt.

    modify it_tab.

    endloop.

    perform output.

    end-of-selection.

    ----


    • FORM output *

    ----


    • ........ *

    ----


    form output.

    check not it_tab[] is initial.

    • Vorbereiten des Funktionsbausteinsaufrufs.

    hrepid = sy-repid.

    perform fieldcat_init using gt_fieldcat[].

    perform eventtab_build using gt_events[].

    perform layout_build using gs_layout.

    perform excluding_fcode using gt_excluding[].

    • SORT AUSGABE2 BY VBELN.

    • Aufruf

    call function 'REUSE_ALV_GRID_DISPLAY'

    exporting

    • I_INTERFACE_CHECK = ' '

    i_callback_program = hrepid

    i_callback_pf_status_set = 'SET_PF_STATUS'

    i_callback_user_command = 'USER_COMMAND'

    • i_structure_name = 'ZCREDCARD'

    is_layout = gs_layout

    it_fieldcat = gt_fieldcat[]

    it_excluding = gt_excluding[]

    • IT_SPECIAL_GROUPS =

    • IT_SORT =

    • IT_FILTER =

    • IS_SEL_HIDE =

    • I_DEFAULT = 'X'

    i_save = 'A'

    is_variant = g_variant

    it_events = gt_events[]

    • IT_EVENT_EXIT =

    • IS_PRINT =

    • I_SCREEN_START_COLUMN = 0

    • I_SCREEN_START_LINE = 0

    • I_SCREEN_END_COLUMN = 0

    • I_SCREEN_END_LINE = 0

    • IMPORTING

    • E_EXIT_CAUSED_BY_CALLER =

    • ES_EXIT_CAUSED_BY_USER =

    tables

    t_outtab = it_tab

    exceptions

    program_error = 1

    others = 2.

    endform. " OUTPUT

    ----


    • FORM fieldcat_init *

    ----


    • ........ *

    ----


    • --> GT_FIELDCAT *

    ----


    form fieldcat_init using gt_fieldcat type slis_t_fieldcat_alv.

    data: gs_fieldcat type slis_fieldcat_alv.

    call function 'REUSE_ALV_FIELDCATALOG_MERGE'

    exporting

    i_program_name = hrepid

    i_internal_tabname = 'IT_TAB'

    i_inclname = hrepid

    changing

    ct_fieldcat = gt_fieldcat[]

    exceptions

    inconsistent_interface = 1

    program_error = 2

    others = 3.

    • change column headers

    data : w_tabix like sy-tabix.

    loop at gt_fieldcat into gs_fieldcat.

    w_tabix = sy-tabix.

    case gs_fieldcat-fieldname.

    when 'MARK'.

    gs_fieldcat-no_out = 'X'.

    endcase.

    modify gt_fieldcat from gs_fieldcat index w_tabix.

    endloop.

    endform. " FIELDCAT_INIT

    ----


    • FORM eventtab_build *

    ----


    • ........ *

    ----


    • --> GT_EVENTS *

    ----


    form eventtab_build using gt_events type slis_t_event.

    data: ls_event type slis_alv_event.

    *

    call function 'REUSE_ALV_EVENTS_GET'

    exporting

    i_list_type = 0

    importing

    et_events = gt_events.

    • CHECK 1 = 2.

    • READ TABLE GT_EVENTS INTO LS_EVENT

    • WITH KEY NAME = 'PF_STATUS_SET'.

    • IF SY-SUBRC = 0.

    • LS_EVENT-FORM = 'SET_PF_STATUS'. APPEND LS_EVENT TO GT_EVENTS .

    • ENDIF.

    endform. " EVENTTAB_BUILD

    ----


    • FORM layout_build *

    ----


    • ........ *

    ----


    • --> GS_LAYOUT *

    ----


    form layout_build using gs_layout type slis_layout_alv.

    gs_layout-box_fieldname = 'MARK'.

    gs_layout-box_tabname = 'IT_TAB'.

    gs_layout-lights_tabname = 'IT_TAB'.

    gs_layout-lights_fieldname = 'AMPEL'.

    • GS_LAYOUT-GROUP_BUTTONS = 'X'.

    gs_layout-zebra = 'X'.

    gs_layout-colwidth_optimize = 'X'.

    endform. " LAYOUT_BUILD

    ----


    • FORM excluding_fcode *

    ----


    • ........ *

    ----


    • --> GT_EXCLUDING *

    ----


    form excluding_fcode using gt_excluding type slis_t_extab.

    data hgt_excluding type slis_extab.

    • &OL2/3 nicht aktiv

    hgt_excluding-fcode = '&OL1'. append hgt_excluding to gt_excluding.

    hgt_excluding-fcode = '&OL2'. append hgt_excluding to gt_excluding.

    hgt_excluding-fcode = '&OL3'. append hgt_excluding to gt_excluding.

    hgt_excluding-fcode = '&OL4'. append hgt_excluding to gt_excluding.

    hgt_excluding-fcode = '&OL5'. append hgt_excluding to gt_excluding.

    endform. " EXCLUDING_FCODE

    form set_pf_status using rt_extab type slis_t_extab.

    • SET PF STATUS

    set pf-status 'LIST_STATUS'." excluding rt_extab.

    endform. " LAYOUT_BUILD

    ----


    • FORM user_command *

    ----


    • ........ *

    ----


    • --> R_UCOMM *

    • --> RS_SELFIELD *

    ----


    form user_command using r_ucomm like sy-ucomm

    rs_selfield type slis_selfield.

    data : w_count TYPE I.

    clear w_count.

    case r_ucomm.

    when 'EXEC'.

    loop at it_tab where mark = 'X'.

    htabix = sy-tabix.

    w_count = w_count + 1.

    if w_count = 1.

    update skb1 set altkt = it_tab-lokkt2

    where bukrs = it_tab-bukrs

    and saknr = it_tab-hkont.

    endif.

    update bseg set lokkt = it_tab-lokkt2

    where bukrs = it_tab-bukrs

    and belnr = it_tab-belnr

    and gjahr = it_tab-gjahr

    and buzei = it_tab-buzei.

    it_tab-ampel = '3'.

    modify it_tab index htabix.

    endloop.

    endcase.

    endform.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 04, 2007 at 02:57 PM

    hi,

    look F1 to read line

    DO.

    READ LINE SY-INDEX FIELD VALUE

    ztab-XFELD INTO MARK2

    stab-bukrs INTO Bk1

    stab-kunnr INTO kun.

    IF SY-SUBRC NE 0.

    EXIT.

    ENDIF.

    READ TABLE stab WITH KEY Bukrs = Bk1 kunnr

    ...

    A.

    Message was edited by:

    Andreas Mann

    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.