Skip to Content
-1

HIDING A COLUMN IN ALV GRID WHOSE PROFIT CENTER DON'T HAVE DATA.

hai guys,please corrent my code.
if profit center dont have data, i dont want display in alv.
so i just want to show in alv, only those whose profit center has data.
" Profit Center
 SELECT prctr FROM zpi_map_plant INTO CORRESPONDING FIELDS OF TABLE it_map_plant WHERE werks = wa_master-werks.
 IF sy-subrc = 0.
 SELECT SINGLE prctr FROM zpi_map_plant INTO wa_item_master-prctr WHERE werks = wa_stock-werks.
 ELSE.
 SELECT SINGLE prctr_klinik FROM zpi_map_plant INTO wa_item_master-prctr WHERE werks_klinik = wa_stock-werks.
 SELECT SINGLE prctr_klinik FROM zpi_map_plant INTO wa_item_master-prctr_klinik WHERE werks_klinik = wa_stock-werks.
 ENDIF.

FORM show_alv.
 lo_layout-zebra = 'X'.
 lo_layout-colwidth_optimize = 'X'.
 lo_layout-info_fieldname = 'COLOR'.
 ls_variant-report = sy-repid.
 CLEAR wa_event.
 MOVE 'TOP_OF_PAGE' TO wa_event-name.
 MOVE 'TOP_OF_PAGE' TO wa_event-form.
 APPEND wa_event TO events.
 grids-coll_top_p = 'X'.
 PERFORM fill_structure.
 IF opty EQ 'X'.
 CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
 EXPORTING
 i_callback_program = sy-repid
 it_fieldcat = it_fieldcat
 i_default = 'X'
 i_save = 'A'
 TABLES
 t_outtab = it_item_stock_assigned[].
 ELSEIF optn EQ 'X'.
 CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
 EXPORTING
 i_callback_program = sy-repid
 it_fieldcat = it_fieldcat
 i_default = 'X'
 i_save = 'A'
 " i_background_id = d_alv_bg_id
 TABLES
 t_outtab = it_item_stock_not_assigned[].
 ENDIF.
ENDFORM.
FORM set_pop_custom USING rt_extab TYPE slis_t_extab.
 REFRESH rt_extab.
 SET PF-STATUS '4000'.
ENDFORM.
FORM user_command_change USING p_comm TYPE sy-ucomm
 wa_selfield TYPE slis_selfield.
 CASE p_comm.
 WHEN 'BACK'.
 LEAVE TO SCREEN 0.
 WHEN 'CLOSE'.
 LEAVE TO SCREEN 0.
 WHEN 'EXIT'.
 LEAVE TO SCREEN 0.
 WHEN '&XLS'.
 " PERFORM save_excel_0030.
 ENDCASE.
ENDFORM.



Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Oct 24, 2019 at 11:14 AM

    Delete the rows from table "it_item_stock_assigned" whose profit center is blank.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 24, 2019 at 11:16 AM

    Either retrieve lines from your database table that have a profit center( in SELECT statement add WHERE prctr NE space) or Delete those lines that don't have profit center from your internal table.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 24, 2019 at 12:41 PM

    Hello Putri Mulia,

    You must replace your profit center code as below:

    " Profit Center
    SELECT prctr FROM zpi_map_plant INTO CORRESPONDING FIELDS OF TABLE it_map_plant 
    WHERE werks = wa_master-werks.
    
    IF sy-subrc = 0.
      SELECT SINGLE prctr FROM zpi_map_plant INTO wa_item_master-prctr 
      WHERE werks = wa_stock-werks AND prctr NE space.
    ELSE.
      SELECT SINGLE prctr_klinik FROM zpi_map_plant INTO wa_item_master-prctr 
      WHERE werk    s_klinik = wa_stock-werks AND prctr NE space.
    ENDIF.

    Regards!

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 25, 2019 at 03:29 AM

    hai guys,

    i try to put "CODE AND PRCTR NE SPACE" like Satish Kumar Balasubramanian recommend.

    but data that does not have a profit center still appear.

    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.