Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Display output

Former Member
0 Likes
1,717

Hi,

In my report each record will have KCQTY for one month SPMON, I want to display only that month in the display. How can I do this.

Suppose if record num 1 has kcqty for month 09, then only september has to be in the display with kcqty.

Please help me with the problem.

Thanks,

Veni.

FORM get_data.

SELECT spmon konob vkorg kunnr vtweg kcqty

FROM s940 INTO TABLE is940

WHERE konob = p_konob.

ENDFORM. " get_data

FORM process_data.

SORT is940 BY kunnr.

LOOP AT is940.

MOVE is940-konob TO iout-konob.

MOVE is940-kunnr TO iout-kunnr.

MOVE is940-vkorg TO iout-vkorg.

MOVE is940-vtweg TO iout-vtweg.

IF is940-spmon+4(2) = '01'.

MOVE is940-kcqty TO iout-month1.

ELSEIF is940-spmon+4(2) = '02'.

MOVE is940-kcqty TO iout-month2.

ELSEIF is940-spmon+4(2) = '03'.

MOVE is940-kcqty TO iout-month3.

ELSEIF is940-spmon+4(2) = '04'.

MOVE is940-kcqty TO iout-month4.

ELSEIF is940-spmon+4(2) = '05'.

MOVE is940-kcqty TO iout-month5.

ELSEIF is940-spmon+4(2) = '06'.

MOVE is940-kcqty TO iout-month6.

ELSEIF is940-spmon+4(2) = '07'.

MOVE is940-kcqty TO iout-month7.

ELSEIF is940-spmon+4(2) = '08'.

MOVE is940-kcqty TO iout-month8.

ELSEIF is940-spmon+4(2) = '09'.

MOVE is940-kcqty TO iout-month9.

ELSEIF is940-spmon+4(2) = '10'.

MOVE is940-kcqty TO iout-month10.

ELSEIF is940-spmon+4(2) = '11'.

MOVE is940-kcqty TO iout-month11.

ELSEIF is940-spmon+4(2) = '12'.

MOVE is940-kcqty TO iout-month12.

ENDIF.

APPEND iout.

CLEAR iout.

CLEAR is940.

ENDLOOP.

ENDFORM. " process_data

1 ACCEPTED SOLUTION
Read only

naimesh_patel
Active Contributor
0 Likes
1,683

Are you using ALV?

Than you can set the FIELD_CAT-NO_OUT = 'X' for those fields which don't have values.

Like:

For field month1:

clear l_flag.
LOOP AT iout where month1 is not initial.
l_flag = 'X'.
exit.
endloop.

if l_flag is initial.
  FIELD_CAT-NO_OUT = 'X' 
endif.

You need to do it for all fields. You can use the field symbol to avoid the repeating code.

Regards,

Naimesh Patel

18 REPLIES 18
Read only

naimesh_patel
Active Contributor
0 Likes
1,684

Are you using ALV?

Than you can set the FIELD_CAT-NO_OUT = 'X' for those fields which don't have values.

Like:

For field month1:

clear l_flag.
LOOP AT iout where month1 is not initial.
l_flag = 'X'.
exit.
endloop.

if l_flag is initial.
  FIELD_CAT-NO_OUT = 'X' 
endif.

You need to do it for all fields. You can use the field symbol to avoid the repeating code.

Regards,

Naimesh Patel

Read only

0 Likes
1,683

Hi Naimesh,

I am using ALV display. Can you please let me know, where I should use FIELD_CAT-NO_OUT.

Thanks

Veni.


REPORT zsdr_prod_allocation NO STANDARD PAGE HEADING.

TABLES: s940.

INCLUDE zalvi_grid_display.

DATA: g_repid   LIKE sy-repid.

*----------------------------------------------------------------------*
* Input Tables
*----------------------------------------------------------------------*

DATA: BEGIN OF is940 OCCURS 0,
        spmon     LIKE s940-spmon,
        konob     LIKE s940-konob,
        vkorg     LIKE s940-vkorg,
        kunnr     LIKE s940-kunnr,
        vtweg     LIKE s940-vtweg,
        kcqty     LIKE s940-kcqty,
     END OF is940.

*----------------------------------------------------------------------*
* Output Table
*----------------------------------------------------------------------*

DATA: BEGIN OF iout OCCURS 0,
        konob     LIKE s940-konob,
        kunnr     LIKE s940-kunnr,
        vkorg     LIKE s940-vkorg,
        vtweg     LIKE s940-vtweg,
        month1    LIKE s940-kcqty,
        month2    LIKE s940-kcqty,
        month3    LIKE s940-kcqty,
        month4    LIKE s940-kcqty,
        month5    LIKE s940-kcqty,
        month6    LIKE s940-kcqty,
        month7    LIKE s940-kcqty,
        month8    LIKE s940-kcqty,
        month9    LIKE s940-kcqty,
        month10   LIKE s940-kcqty,
        month11   LIKE s940-kcqty,
        month12   LIKE s940-kcqty,
END OF iout.

*----------------------------------------------------------------------*
* SELECTION SCREEN
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_konob LIKE s940-konob OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.
*----------------------------------------------------------------------*
* START-OF-SELECTION
*----------------------------------------------------------------------*
START-OF-SELECTION.
  PERFORM get_data.
  PERFORM process_data.
  PERFORM sub_alv_routines.
  PERFORM comment_build  USING t_list_top_of_page[].
  g_repid = sy-repid.
  PERFORM alv_build_fieldcat USING 'IOUT' g_repid.
  PERFORM sub_modify_field_cat.
  PERFORM sub_call_alv_grid TABLES iout.

*&---------------------------------------------------------------------*
*&      Form  getdata
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM get_data.

  SELECT spmon konob vkorg kunnr vtweg kcqty
      FROM s940 INTO TABLE is940
      WHERE konob = p_konob.

ENDFORM.                    " get_data

*&---------------------------------------------------------------------*
*&      Form  process_data
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM process_data.

  SORT is940 BY kunnr.

  LOOP AT is940.

    MOVE is940-konob TO iout-konob.
    MOVE is940-kunnr TO iout-kunnr.
    MOVE is940-vkorg TO iout-vkorg.
    MOVE is940-vtweg TO iout-vtweg.

    IF is940-spmon+4(2) = '01'.
      MOVE is940-kcqty TO iout-month1.
    ELSEIF is940-spmon+4(2) = '02'.
      MOVE is940-kcqty TO iout-month2.
    ELSEIF is940-spmon+4(2) = '03'.
      MOVE is940-kcqty TO iout-month3.
    ELSEIF is940-spmon+4(2) = '04'.
      MOVE is940-kcqty TO iout-month4.
    ELSEIF is940-spmon+4(2) = '05'.
      MOVE is940-kcqty TO iout-month5.
    ELSEIF is940-spmon+4(2) = '06'.
      MOVE is940-kcqty TO iout-month6.
    ELSEIF is940-spmon+4(2) = '07'.
      MOVE is940-kcqty TO iout-month7.
    ELSEIF is940-spmon+4(2) = '08'.
      MOVE is940-kcqty TO iout-month8.
    ELSEIF is940-spmon+4(2) = '09'.
      MOVE is940-kcqty TO iout-month9.
    ELSEIF is940-spmon+4(2) = '10'.
      MOVE is940-kcqty TO iout-month10.
    ELSEIF is940-spmon+4(2) = '11'.
      MOVE is940-kcqty TO iout-month11.
    ELSEIF is940-spmon+4(2) = '12'.
      MOVE is940-kcqty TO iout-month12.
    ENDIF.

    APPEND iout.
    CLEAR iout.
    CLEAR is940.
  ENDLOOP.
ENDFORM.                    " process_data

*&---------------------------------------------------------------------
*&      Form  top_of_page
*&---------------------------------------------------------------------
*       This subroutine handles placement of standard report headers.
*----------------------------------------------------------------------
FORM top_of_page .
  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
           EXPORTING
             i_logo             = 'HTMLCNTL_TESTHTM2_SAPLOGO'
*              i_logo             = 'ENJOYSAP_LOGO'
                it_list_commentary = t_list_top_of_page.

ENDFORM.                    "top_of_page

*&---------------------------------------------------------------------
*
*&      Form  comment_build
*&---------------------------------------------------------------------
*
*       text
*----------------------------------------------------------------------
*
*      -->P_T_LIST_TOP_OF_PAGE[]  text
*----------------------------------------------------------------------

FORM comment_build USING lt_top_of_page TYPE slis_t_listheader.
  DATA: ls_line TYPE slis_listheader.

* User Name
  CLEAR ls_line.
  ls_line-typ  = 'S'.
  ls_line-key  = 'User Name:'.
  ls_line-info   = sy-uname.
  APPEND ls_line TO lt_top_of_page.

*  Date
  CLEAR ls_line.
  ls_line-typ  = 'S'.
  ls_line-key  = 'Date:'.
  ls_line-info = sy-datum.
  APPEND ls_line TO lt_top_of_page.

* Time
  CLEAR ls_line.
  ls_line-typ  = 'S'.
  ls_line-key  = 'Time:'.
  ls_line-info   = sy-uzeit.
  APPEND ls_line TO lt_top_of_page.

* Product Allocation object
  CLEAR ls_line.
  ls_line-typ  = 'S'.
  ls_line-key  = 'Prod Allocation Obj:'.
  ls_line-info   = p_konob.
  APPEND ls_line TO lt_top_of_page.

ENDFORM.                    " comment_build

*&---------------------------------------------------------------------
*
*&      Form  sub_modify_field_cat
*&---------------------------------------------------------------------
*
*       text
*----------------------------------------------------------------------
*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------
*
FORM sub_modify_field_cat.

  LOOP AT it_alv_field_cat INTO w_fieldcat.

    CASE w_fieldcat-fieldname.
      WHEN 'MONTH1'.
        w_fieldcat-seltext_s = 'JANUARY'(017).
        w_fieldcat-seltext_m = 'JANUARY'(17m).
        w_fieldcat-seltext_l = 'JANUARY'(17l).
        w_fieldcat-ddictxt = 'L'.

      WHEN 'MONTH2'.
        w_fieldcat-seltext_s = 'FEBRUARY'(017).
        w_fieldcat-seltext_m = 'FEBRUARY'(17m).
        w_fieldcat-seltext_l = 'FEBRUARY'(17l).
        w_fieldcat-ddictxt = 'L'.

      WHEN 'MONTH3'.
        w_fieldcat-seltext_s = 'MARCH'(017).
        w_fieldcat-seltext_m = 'MARCH'(17m).
        w_fieldcat-seltext_l = 'MARCH'(17l).
        w_fieldcat-ddictxt = 'L'.

      WHEN 'MONTH4'.
        w_fieldcat-seltext_s = 'APRIL'(017).
        w_fieldcat-seltext_m = 'APRIL'(17m).
        w_fieldcat-seltext_l = 'APRIL'(17l).
        w_fieldcat-ddictxt = 'L'.

      WHEN 'MONTH5'.
        w_fieldcat-seltext_s = 'MAY'(017).
        w_fieldcat-seltext_m = 'MAY'(17m).
        w_fieldcat-seltext_l = 'MAY'(17l).
        w_fieldcat-ddictxt = 'L'.

      WHEN 'MONTH6'.
        w_fieldcat-seltext_s = 'JUNE'(017).
        w_fieldcat-seltext_m = 'JUNE'(17m).
        w_fieldcat-seltext_l = 'JUNE'(17l).
        w_fieldcat-ddictxt = 'L'.

      WHEN 'MONTH7'.
        w_fieldcat-seltext_s = 'JULY'(017).
        w_fieldcat-seltext_m = 'JULY'(17m).
        w_fieldcat-seltext_l = 'JULY'(17l).
        w_fieldcat-ddictxt = 'L'.

      WHEN 'MONTH8'.
        w_fieldcat-seltext_s = 'AUGUST'(017).
        w_fieldcat-seltext_m = 'AUGUST'(17m).
        w_fieldcat-seltext_l = 'AUGUST'(17l).
        w_fieldcat-ddictxt = 'L'.

      WHEN 'MONTH9'.
        w_fieldcat-seltext_s = 'SEPTEMBER'(017).
        w_fieldcat-seltext_m = 'SEPTEMBER'(17m).
        w_fieldcat-seltext_l = 'SEPTEMBER'(17l).
        w_fieldcat-ddictxt = 'L'.

      WHEN 'MONTH10'.
        w_fieldcat-seltext_s = 'OCTOBER'(017).
        w_fieldcat-seltext_m = 'OCTOBER'(17m).
        w_fieldcat-seltext_l = 'OCTOBER'(17l).
        w_fieldcat-ddictxt = 'L'.

      WHEN 'MONTH11'.
        w_fieldcat-seltext_s = 'NOVEMBER'(017).
        w_fieldcat-seltext_m = 'NOVEMBER'(17m).
        w_fieldcat-seltext_l = 'NOVEMBER'(17l).
        w_fieldcat-ddictxt = 'L'.

      WHEN 'MONTH12'.
        w_fieldcat-seltext_s = 'DECEMBER'(017).
        w_fieldcat-seltext_m = 'DECEMBER'(17m).
        w_fieldcat-seltext_l = 'DECEMBER'(17l).
        w_fieldcat-ddictxt = 'L'.

    ENDCASE.

    MODIFY it_alv_field_cat FROM w_fieldcat . "Modify fieldcatalog
  ENDLOOP.

ENDFORM.             " sub_modify_field_cat

Read only

0 Likes
1,683

Hi,

I am using ALV display only. Can you please let me know, where I should use FIELD_CAT-NO_OUT. Can someone please help me with it.

Thanks

Veni.

Read only

0 Likes
1,683

Hi,

Can some one please help me to display only the months with KCQTY.

Thanks,

Veni.

Read only

0 Likes
1,683

In your <b>FORM sub_modify_field_cat.</b>

Sorry, I have orverlooked your reply.

Regards,

Naimesh Patel

Read only

0 Likes
1,683

Hi Naimesh,

I saw no_out in 'w_fieldcat-> i_fieldcat-> slis_fieldcat_alv-> slis_fieldcat_main-> slis_fieldcat_main0' but it is giving me error like Field"W_FIELD_CAT-NO_OUT" is unknown. It is neither in one of the specified tables nor defind by a "DATA" statement. We are using 4.6C.

Please help me if I did anything wrong.

WHEN 'MONTH1'.

CLEAR l_flag.

LOOP AT iout WHERE not month1 IS INITIAL.

l_flag = 'X'.

EXIT.

ENDLOOP.

IF l_flag IS INITIAL.

w_field_cat-no_out = 'X'.

endif.

w_fieldcat-seltext_s = 'JANUARY'(017).

w_fieldcat-seltext_m = 'JANUARY'(17m).

w_fieldcat-seltext_l = 'JANUARY'(17l).

w_fieldcat-ddictxt = 'L'.

Thanks,

Veni.

Read only

0 Likes
1,683

Hi Veni,

Have you declared this

data: w_field_cat TYPE lvc_s_fcat.

I think you might have declared as w_fieldcat, remove second underscore in w_field_cat.

Regards,

Satish

Message was edited by:

Satish Panakala

Read only

0 Likes
1,683

Thank you Satish, I changed it and saw your reply. Thanks alot.

Regards,

Veni.

Read only

0 Likes
1,683

So, is your problem solved now?

Read only

0 Likes
1,683

Hi,

This w_fieldcat-no_out = 'X' worked well. I did not see January month which does not have any qty. How should I use field symbol. I have never used it before.

Thanks,

Veni.

Read only

Read only

0 Likes
1,683

This is the way to use the field-symbol...

data: l_cnt(2) type c,
l_field(20).

DO 12 times.
  l_cnt = sy-index.

  concatenate 'MONTH' l_cnt into l_field.
  condense l_field.
  clear l_flag.

  LOOP AT iout where (l_field) is not initial.
    l_flag = 'X'.
    exit.
  endloop.
 
  if  l_flag is initial.
    FIELD_CAT-NO_OUT = 'X' .
    modify field_cat transporting no_out where fieldname = l_field.
  endif.

ENDDO.

Regards,

Naimesh Patel

Read only

0 Likes
1,683

Hi,

Thank you Naimesh and Satish.

I have the following problem now.

Instead of this display output,

sold to sorg dchl august september october november

1057 300 20 20.000 100.000 200.000 400.0000.000

it is comming like the following.

sold to sorg dchl august september october november

1057 300 20 20.000 0.000 0.000 0.000

1057 300 20 0.000 100.000 0.000 0.000

1057 300 20 0.000 0.000 200.000 0.000

1057 300 20 0.000 0.000 0.000 400.000

Please help me to fix this.

Thanks,

veni.

Read only

0 Likes
1,683

I think you should use COLLECT instead of the APPEND

  LOOP AT is940.
 
    MOVE is940-konob TO iout-konob.
    MOVE is940-kunnr TO iout-kunnr.
    MOVE is940-vkorg TO iout-vkorg.
    MOVE is940-vtweg TO iout-vtweg.
 
    IF is940-spmon+4(2) = '01'.
      MOVE is940-kcqty TO iout-month1.
    ELSEIF is940-spmon+4(2) = '02'.
      MOVE is940-kcqty TO iout-month2.
    ELSEIF is940-spmon+4(2) = '03'.
      MOVE is940-kcqty TO iout-month3.
    ELSEIF is940-spmon+4(2) = '04'.
      MOVE is940-kcqty TO iout-month4.
    ELSEIF is940-spmon+4(2) = '05'.
      MOVE is940-kcqty TO iout-month5.
    ELSEIF is940-spmon+4(2) = '06'.
      MOVE is940-kcqty TO iout-month6.
    ELSEIF is940-spmon+4(2) = '07'.
      MOVE is940-kcqty TO iout-month7.
    ELSEIF is940-spmon+4(2) = '08'.
      MOVE is940-kcqty TO iout-month8.
    ELSEIF is940-spmon+4(2) = '09'.
      MOVE is940-kcqty TO iout-month9.
    ELSEIF is940-spmon+4(2) = '10'.
      MOVE is940-kcqty TO iout-month10.
    ELSEIF is940-spmon+4(2) = '11'.
      MOVE is940-kcqty TO iout-month11.
    ELSEIF is940-spmon+4(2) = '12'.
      MOVE is940-kcqty TO iout-month12.
    ENDIF.
 
*    APPEND iout.   
    COLLECT IOUT.   " <<<
    CLEAR iout.
    CLEAR is940.
  endloop.

Regards,

Naimesh Patel

Read only

0 Likes
1,683

Veni,

Somewhere you have not cleared the workarea

Clear workareas after modify or append statement.

Satish

Read only

0 Likes
1,683

Thank you Naimesh and Satish.

My problem got solved. I really appriciate all your help.

Regards,

Veni.

Read only

Former Member
0 Likes
1,683

Hi,

before displaying the out from internal table, delete iout where kcqty = ' '.

reward points if it helps,

Satish

Read only

Former Member
0 Likes
1,683

hey

try to use function module 'MONTH_NAMES_GET' .

use this just before displayng the output. i.e within loop and before write statement.

and in write statement use imported value from this function module instead of number of the month.

your problem will be solved.

CHEERS