Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

REFRESH FUNCTIONALITy in ALV GRID

Hi Experts,

I have added two custom buttons (CO40 and REFRESH) in ALV GRID .

WHEN CO40 button is clicked it will go the CO40 transaction.

here the problem is when clicking the REFRESH , the REFRESH fuctionality is not working.

(here i went to CO40 transaction by clicking CO40 button and deleted one planned order and come back and clicked REFRESH button but the planned order still showing in the output but the planned oreder is deleted in the table ) please help me rgarding this

pls see my code and pls send me the code with modifications

Thanks

Nagendra

REPORT zpp_plannedorder_conv LINE-SIZE 200.

TYPE-POOLS: slis.

TABLES: plaf, vbak.

        • PLANNED ORDER TABLE

CONSTANTS: c_e TYPE c LENGTH 01 VALUE 'E'.

TYPES: BEGIN OF ty_plaf,

kdauf TYPE kdauf,

kdpos TYPE kdpos,

plnum TYPE plnum,

dispo TYPE dispo,

matnr TYPE matnr,

maktx TYPE maktx,

pwwrk TYPE pwwrk,

paart TYPE paart,

beskz TYPE beskz,

gsmng TYPE gsmng,

END OF ty_plaf.

        • SALES FIELDS

TYPES: BEGIN OF ty_vbak,

vbeln TYPE vbeln,

posnr TYPE posnr,

kunnr TYPE kunnr,

grkor TYPE grkor,

autlf TYPE autlf,

mvgr2 TYPE mvgr2,

fixmg TYPE fixmg,

bstdk TYPE bstdk,

edatu TYPE edatu,

posex TYPE posex,

END OF ty_vbak.

        • output table.

TYPES: BEGIN OF ty_out,

plnum TYPE plnum,

dispo TYPE dispo,

matnr TYPE matnr,

maktx TYPE maktx,

pwwrk TYPE pwwrk,

paart TYPE paart,

beskz TYPE beskz,

gsmng TYPE gsmng,

kdauf TYPE kdauf,

kdpos TYPE kdpos,

kunnr TYPE kunnr,

grkor TYPE grkor,

autlf TYPE autlf,

mvgr2 TYPE mvgr2,

fixmg TYPE fixmg,

bstdk TYPE bstdk,

edatu TYPE edatu,

posex TYPE posex,

END OF ty_out.

DATA: tb_plaf TYPE STANDARD TABLE OF ty_plaf,

tb_vbak TYPE STANDARD TABLE OF ty_vbak,

tb_out TYPE STANDARD TABLE OF ty_out.

DATA: lv_plaf TYPE ty_plaf,

lv_vbak TYPE ty_vbak,

lv_out TYPE ty_out.

*

TYPES: BEGIN OF ty_vbep,

vbeln TYPE vbeln,

posnr TYPE posnr,

etenr TYPE etenr,

edatu TYPE edatu,

END OF ty_vbep.

*

DATA: tb_vbep TYPE STANDARD TABLE OF ty_vbep.

DATA: lv_flag(1) TYPE c.

**Start changes RFS: SANN - 0856

DATA: w_repid TYPE sy-repid.

DATA: it_fieldcat TYPE slis_t_fieldcat_alv, "field catalog table

gs_layout TYPE slis_layout_alv, "struct data type

it_sort TYPE slis_t_sortinfo_alv,

it_events TYPE slis_t_event,

gt_event_exit TYPE slis_t_event_exit.

**End changes RFS: SANN - 0856

          • SELECT OPTIONS.

SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE text-t01.

SELECT-OPTIONS: sel_pln FOR plaf-plnum,

sel_pww FOR plaf-pwwrk OBLIGATORY,

sel_dis FOR plaf-dispo,

sel_kun FOR vbak-kunnr,

sel_paa FOR plaf-paart,

sel_kda FOR plaf-kdauf.

SELECTION-SCREEN END OF BLOCK a1.

START-OF-SELECTION.

REFRESH: tb_plaf ,tb_vbak.

SELECT pkdauf pkdpos pplnum pdispo pmatnr mmaktx

ppwwrk ppaart pbeskz pgsmng INTO TABLE tb_plaf

FROM plaf AS p JOIN makt AS m

ON pmatnr EQ mmatnr

WHERE p~plnum IN sel_pln

AND p~pwwrk IN sel_pww

AND p~dispo IN sel_dis

AND p~paart IN sel_paa

AND p~kdauf IN sel_kda

AND m~spras EQ c_e.

IF NOT tb_plaf[] IS INITIAL.

SORT tb_plaf BY kdauf DESCENDING.

SELECT kvbeln pposnr kkunnr pgrkor kautlf pmvgr2 p~fixmg

kbstdk vedatu p~posex INTO TABLE tb_vbak

FROM vbak AS k JOIN vbap AS p

ON kvbeln EQ pvbeln

INNER JOIN vbep AS v

ON pvbeln EQ vvbeln

AND pposnr EQ vposnr

FOR ALL ENTRIES IN tb_plaf

WHERE k~vbeln EQ tb_plaf-kdauf

AND p~posnr EQ tb_plaf-kdpos

AND k~kunnr IN sel_kun

AND v~etenr EQ '0001'.

IF NOT tb_vbak[] IS INITIAL.

LOOP AT tb_plaf INTO lv_plaf.

CLEAR lv_out.

MOVE-CORRESPONDING lv_plaf TO lv_out.

IF NOT lv_plaf-kdauf IS INITIAL.

READ TABLE tb_vbak INTO lv_vbak WITH KEY vbeln = lv_plaf-kdauf

posnr = lv_plaf-kdpos.

MOVE-CORRESPONDING lv_vbak TO lv_out.

ENDIF.

APPEND lv_out TO tb_out.

ENDLOOP.

ENDIF.

ENDIF.

END-OF-SELECTION.

PERFORM f_build_fcat.

PERFORM f_get_display.

*&----


*& Form F_BUILD_FCAT

*&----


FORM f_build_fcat .

CLEAR: w_repid.

PERFORM fill_fieldcat " TABLES it_fieldcat

USING:

text-f01 'TB_OUT' text-k01 text-k01 '10' ,

text-f02 'TB_OUT' text-k02 text-k02 '10' ,

text-f03 'TB_OUT' text-k03 text-k03 '06' ,

text-f04 'TB_OUT' text-k04 text-k04 '18' ,

text-f05 'TB_OUT' text-k05 text-k05 '06' ,

text-f06 'TB_OUT' text-k06 text-k06 '08' ,

text-f07 'TB_OUT' text-k07 text-k07 '05' ,

text-f08 'TB_OUT' text-k08 text-k08 '05' ,

text-f09 'TB_OUT' text-k09 text-k09 '15' ,

text-f10 'TB_OUT' text-k10 text-k10 '05' ,

text-f11 'TB_OUT' text-k11 text-k11 '05' ,

text-f12 'TB_OUT' text-k12 text-k12 '10' ,

text-f13 'TB_OUT' text-k13 text-k13 '10' ,

text-f14 'TB_OUT' text-k14 text-k14 '10' ,

text-f15 'TB_OUT' text-t15 text-k15 '10' ,

text-f16 'TB_OUT' text-k16 text-k16 '10' ,

text-f17 'TB_OUT' text-k17 text-k17 '10' .

ENDFORM. " F_BUILD_FCAT

&----


*& Form fill_fieldcat

&----


FORM fill_fieldcat " TABLES l_catalog TYPE slis_t_fieldcat_alv "#EC *

USING p_field "#EC *

p_table "#EC *

p_desc "#EC *

p_desc_l "#EC *

p_len. "#EC *

DATA: ls_fieldcat TYPE slis_fieldcat_alv.

ls_fieldcat-fieldname = p_field.

ls_fieldcat-tabname = p_table.

ls_fieldcat-seltext_l = p_desc_l.

ls_fieldcat-reptext_ddic = p_desc.

ls_fieldcat-outputlen = p_len.

APPEND ls_fieldcat TO it_fieldcat.

CLEAR ls_fieldcat.

ENDFORM. " fill_fieldcat

&----


*& FORM F_GET_DISPLAY

&----


  • text

----


FORM f_get_display .

CLEAR w_repid.

MOVE sy-repid TO w_repid.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = w_repid

i_callback_pf_status_set = 'PF_STATUS'

i_callback_user_command = 'USER_COMMAND'

is_layout = gs_layout

it_fieldcat = it_fieldcat

it_sort = it_sort

i_save = 'X'

TABLES

t_outtab = tb_out

EXCEPTIONS

program_error = 1

OTHERS = 2.

.

IF sy-subrc EQ 0.

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

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

ENDIF.

ENDFORM. " F_GET_DISPLAY

&----


*& Form PF_STATUS

&----


  • text

----


FORM pf_status USING rt_extab TYPE slis_t_extab.

DATA: wa_extab LIKE LINE OF rt_extab.

REFRESH: rt_extab.

wa_extab-fcode = '&REFRESH'.

APPEND wa_extab TO rt_extab.

SET PF-STATUS '0001' EXCLUDING rt_extab.

ENDFORM. "PF_STATUS

----


  • -->COMMAND text

  • -->SELFIELD text

----


FORM user_command USING command LIKE sy-ucomm selfield TYPE slis_selfield."#EC CALLED

CLEAR : lv_out-plnum,lv_out-kdauf,lv_out-paart,lv_out-kdauf.

CASE command.

WHEN '&IC1'. "doubleclick

CASE selfield-fieldname.

WHEN 'PLNUM'.

READ TABLE tb_out INTO lv_out INDEX selfield-tabindex.

IF sy-subrc EQ 0.

SET PARAMETER ID 'PAF' FIELD lv_out-plnum.

CALL TRANSACTION 'MD12' AND SKIP FIRST SCREEN.

ENDIF.

WHEN 'KDAUF'.

READ TABLE tb_out INTO lv_out INDEX selfield-tabindex.

IF sy-subrc EQ 0.

SET PARAMETER ID 'AUN' FIELD lv_out-kdauf.

CALL TRANSACTION 'VA02' AND SKIP FIRST SCREEN.

ENDIF.

ENDCASE.

WHEN 'CO40'.

READ TABLE tb_out INTO lv_out INDEX selfield-tabindex.

IF sy-subrc EQ 0.

SET PARAMETER ID 'PAF' FIELD lv_out-plnum.

CALL TRANSACTION 'CO40' AND SKIP FIRST SCREEN.

ENDIF.

WHEN 'REFRESH'.

PERFORM select_data.

ENDCASE.

ENDFORM. "user_command

*End changes RFS: SANN - 0856

&----


*& Form SELECT_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM select_data .

commit work and wait.

REFRESH:tb_plaf[],tb_vbak[],tb_out[].

SELECT pkdauf pkdpos pplnum pdispo pmatnr mmaktx

ppwwrk ppaart pbeskz pgsmng INTO TABLE tb_plaf

FROM plaf AS p JOIN makt AS m

ON pmatnr EQ mmatnr

WHERE p~plnum IN sel_pln

AND p~pwwrk IN sel_pww

AND p~dispo IN sel_dis

AND p~paart IN sel_paa

AND p~kdauf IN sel_kda

AND m~spras EQ c_e.

IF NOT tb_plaf[] IS INITIAL.

SORT tb_plaf BY kdauf DESCENDING.

SELECT kvbeln pposnr kkunnr pgrkor kautlf pmvgr2 p~fixmg

kbstdk vedatu p~posex INTO TABLE tb_vbak

FROM vbak AS k JOIN vbap AS p

ON kvbeln EQ pvbeln

INNER JOIN vbep AS v

ON pvbeln EQ vvbeln

AND pposnr EQ vposnr

FOR ALL ENTRIES IN tb_plaf

WHERE k~vbeln EQ tb_plaf-kdauf

AND p~posnr EQ tb_plaf-kdpos

AND k~kunnr IN sel_kun

AND v~etenr EQ '0001'.

IF NOT tb_vbak[] IS INITIAL.

LOOP AT tb_plaf INTO lv_plaf.

CLEAR lv_out.

MOVE-CORRESPONDING lv_plaf TO lv_out.

IF NOT lv_plaf-kdauf IS INITIAL.

READ TABLE tb_vbak INTO lv_vbak WITH KEY vbeln = lv_plaf-kdauf

posnr = lv_plaf-kdpos.

MOVE-CORRESPONDING lv_vbak TO lv_out.

ENDIF.

APPEND lv_out TO tb_out.

ENDLOOP.

ENDIF.

ENDIF.

ENDFORM. " SELECT_DATA

Tags:
Former Member

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question