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

move statement issue

Former Member
0 Likes
1,465

The move statement below can't work, any wrong with the code?

REPORT  ZTESTING_CHHO.

TABLES: KNA1,KNVV,TVKOT.

*--------------------------------------------------------------*

*Data Declaration

*--------------------------------------------------------------*

TYPE-POOLS: slis.                   "ALV Global types

DATA:

  BEGIN OF it_output OCCURS 0,

        KUNNR TYPE KNA1-KUNNR,

        NAME1 TYPE KNA1-NAME1,

        NAME2 TYPE KNA1-NAME2,

        STRAS TYPE KNA1-STRAS,

        ZTERM TYPE KNVV-ZTERM,

        VKORG TYPE KNVV-VKORG,

        VTWEG TYPE KNVV-VTWEG,

        SPART TYPE KNVV-SPART,

  END OF it_output,

  gt_list_top_of_page TYPE slis_t_listheader,"to print header/footer

  gt_list_btm_of_page TYPE slis_t_listheader,"to print header/footer

  gt_events           TYPE slis_t_event,

  gs_layout           TYPE slis_layout_alv,"column width optimize, alternate colors, subtotal text...

  gt_fieldcat         TYPE slis_t_fieldcat_alv."field catalog for internal table

*--------------------------------------------------------------*

*Selection-Screen

*--------------------------------------------------------------*

SELECT-OPTIONS: C_Code FOR KNA1-KUNNR.

AT SELECTION-SCREEN.

IF sy-ucomm = 'ONLI'.

  PERFORM validate_mandatory.

  ENDIF.

*----------------------------------------------------------------------*

* Start of selection

*----------------------------------------------------------------------*

START-OF-SELECTION.

*-----------------*

  PERFORM progress USING 20 'Retrieving Data'.

  PERFORM get_data.

*----------------------------------------------------------------------*

* End of selection

*----------------------------------------------------------------------*

END-OF-SELECTION.

*---------------*

  PERFORM progress USING 60 'Preparing Data'.

  PERFORM build."Build the fields for ALV display

  PERFORM eventtab_build CHANGING gt_events.

  PERFORM comment_build  CHANGING gt_list_top_of_page.

  PERFORM comment_build_btm  CHANGING gt_list_btm_of_page.

  PERFORM call_alv.

*&---------------------------------------------------------------------*

*&      Form  validate_field

*&---------------------------------------------------------------------*

*----------------------------------------------------------------------*

FORM validate_mandatory .

    IF C_Code[] IS INITIAL.

      MESSAGE E014(ZMSG) WITH 'Please insert customer code.'.

    ENDIF.

ENDFORM.                    " validate_field

*&---------------------------------------------------------------------*

*---------------------------------------------------------------------*

*       FORM comment_build_btm

*---------------------------------------------------------------------*

* Summary of the list for ALV display

*---------------------------------------------------------------------*

FORM comment_build_btm CHANGING gt_btm_of_page TYPE slis_t_listheader.

  DATA: gs_line TYPE slis_listheader.

  CLEAR gs_line.

  gs_line-typ = 'S'.

  gs_line-info = 'End of report'.

  APPEND gs_line TO gt_btm_of_page.

ENDFORM.                    "comment_build_btm

*----------------------------------------------------------------------*

*       FORM call_alv

*----------------------------------------------------------------------*

*       Display of ALV screen

*----------------------------------------------------------------------*

FORM call_alv.

  PERFORM progress USING 80 'Generating ALV Grid Display'.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

      i_callback_program = sy-cprog

      is_layout          = gs_layout

      it_fieldcat        = gt_fieldcat[]

      i_save             = 'A'

      it_events          = gt_events[]

    TABLES

      t_outtab           = it_output

    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 comment_build

*---------------------------------------------------------------------*

* Header of the page for ALV display using information from selection

*---------------------------------------------------------------------*

FORM comment_build CHANGING gt_top_of_page TYPE slis_t_listheader.

  DATA: gs_line TYPE slis_listheader.

  DATA: l_datum(10)  TYPE c,          "Date

        l_datumh(10) TYPE c,          "Date High

    l_DBCNT(10)  TYPE c,      "Record Count

        l_uzeit(8)   TYPE c,          "Time

        l_psphi      LIKE prps-posid, "Project Code

        l_psphih     LIKE prps-posid. "Project Code High

  CLEAR gs_line.

  gs_line-typ = 'H'.

  gs_line-info = 'Assignment 3'.

  APPEND gs_line TO gt_list_top_of_page.

  IF NOT C_Code IS INITIAL.

    CLEAR gs_line.

    gs_line-typ = 'S'.

    gs_line-key = 'Customer Code: '.

    IF NOT C_Code-high IS INITIAL.

      CONCATENATE C_Code-low 'to' C_Code-high INTO gs_line-info

        SEPARATED BY space.

    ELSE.

      gs_line-info = C_Code-low.

    ENDIF.

    IF NOT gs_line-info IS INITIAL.

      APPEND gs_line TO gt_list_top_of_page.

    ENDIF.

  ENDIF.

  CLEAR gs_line.

  gs_line-typ = 'A'.

  CONCATENATE 'Client/System/User' ':' sy-mandt '/' sy-sysid

  '/' sy-uname

    INTO gs_line-info SEPARATED BY space.

  APPEND gs_line TO gt_list_top_of_page.

  CLEAR gs_line.

  gs_line-typ = 'A'.

  WRITE: sy-datlo TO l_datum,

         sy-timlo TO l_uzeit.

  CONCATENATE 'Date' ':' l_datum

  INTO gs_line-info SEPARATED BY space.

  APPEND gs_line TO gt_list_top_of_page.

  CONCATENATE 'Time' ':' l_uzeit

  INTO gs_line-info SEPARATED BY space.

  APPEND gs_line TO gt_list_top_of_page.

  CLEAR gs_line .

  WRITE: SY-DBCNT TO l_DBCNT.

  IF L_DBCNT <> 0 .

    gs_line-typ = 'A'.

    CONCATENATE 'Number of records found = ' l_DBCNT

    INTO gs_line-info SEPARATED BY space.

    ELSE .

     gs_line-typ = 'A'.

     gs_line-info = 'No records found, please enter a valid customer code'.

  ENDIF .

  APPEND gs_line TO gt_list_top_of_page.

ENDFORM.                    "comment_build

*---------------------------------------------------------------------*

*       FORM eventtab_build

*---------------------------------------------------------------------*

*       Build event for ALV Display

*---------------------------------------------------------------------*

FORM eventtab_build CHANGING lt_events TYPE slis_t_event.

  CONSTANTS:

  gc_formname_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.

  DATA: ls_event TYPE slis_alv_event.

  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    EXPORTING

      i_list_type     = 0

    IMPORTING

      et_events       = lt_events

    EXCEPTIONS

      list_type_wrong = 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.

  READ TABLE lt_events WITH KEY name =  slis_ev_top_of_page

                           INTO ls_event.

  IF sy-subrc = 0.

    MOVE gc_formname_top_of_page TO ls_event-form.

    APPEND ls_event TO lt_events.

  ENDIF.

  clear ls_event.

  ls_event-name = 'END_OF_LIST'.

  ls_event-form = 'END_OF_REPORT'.

  APPEND ls_event TO lt_events.

ENDFORM.                    "eventtab_build

*---------------------------------------------------------------------*

*       FORM top_of_page

*---------------------------------------------------------------------*

*       Top of the page for ALV display

*---------------------------------------------------------------------*

FORM top_of_page.

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

      it_list_commentary = gt_list_top_of_page

      i_logo             = 'SSG_LOGO'.

ENDFORM.                    "top_of_page

*&---------------------------------------------------------------------*

*&      Form  end_of_report

*&---------------------------------------------------------------------*

*       Write summary before exit

*----------------------------------------------------------------------*

FORM end_of_report .

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

      it_list_commentary = gt_list_btm_of_page.

ENDFORM.

*---------------------------------------------------------------------*

*       FORM build                                                    *

*---------------------------------------------------------------------*

*       Build the fields for ALV display

*---------------------------------------------------------------------*

FORM build.

DATA: fieldcat_ln TYPE slis_fieldcat_alv.

  DEFINE m_fieldcat.

    add 1 to fieldcat_ln-col_pos.

    clear fieldcat_ln.

    fieldcat_ln-fieldname   = &1.

    fieldcat_ln-tabname     = 'IT_OUTPUT'.

    fieldcat_ln-do_sum      = &2.

    fieldcat_ln-cfieldname  = &3.

    fieldcat_ln-no_out      = &4.

    fieldcat_ln-seltext_m   = &5.

    fieldcat_ln-outputlen   = &6.

    append fieldcat_ln to gt_fieldcat.

  END-OF-DEFINITION.

  m_fieldcat 'KUNNR' '' '' ' '    'Customer Code' ''.

  m_fieldcat 'NAME1' '' '' ' '    'Customer Name 1' ''.

  m_fieldcat 'NAME2' '' '' ' '    'Customer Name 2' ''.

  m_fieldcat 'STRAS' '' '' ' '    'Customer Address' ''.

  m_fieldcat 'ZTERM' '' '' ' '    'Payment Term' ''.

  m_fieldcat 'VKORG' '' '' ' '    'Sales Organization' ''.

  m_fieldcat 'VTWEG' '' '' ' '    'Distribution Channel' ''.

  m_fieldcat 'SPART' '' '' ' '    'Division' ''.

ENDFORM.                    "build

*&---------------------------------------------------------------------*

*&      Form  progress

*&---------------------------------------------------------------------*

*       Display Progress bar

*----------------------------------------------------------------------*

FORM progress USING    per

                       text.

  CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

    EXPORTING

      percentage = per

      text       = text.

ENDFORM.                    " progress

*&---------------------------------------------------------------------*

*&      Form  get_proj

*&---------------------------------------------------------------------*

*       Get proj

*----------------------------------------------------------------------*

FORM get_data.

 

  TYPES:

      BEGIN OF ity_MAIN,

        KUNNR TYPE KNA1-KUNNR,

        NAME1 TYPE KNA1-NAME1,

        NAME2 TYPE KNA1-NAME2,

        STRAS TYPE KNA1-STRAS,

        ZTERM TYPE KNVV-ZTERM,

        VKORG TYPE KNVV-VKORG,

        VTWEG TYPE KNVV-VTWEG,

        SPART TYPE KNVV-SPART,

      END OF ity_MAIN.

     

DATA: it_MAIN TYPE STANDARD TABLE OF ity_MAIN WITH HEADER LINE.

  SELECT KNA1~KUNNR KNA1~NAME1 KNA1~NAME2 KNA1~STRAS KNVV~ZTERM KNVV~VKORG KNVV~VTWEG KNVV~SPART

  FROM KNA1 INNER JOIN KNVV

  ON KNA1~KUNNR = KNVV~KUNNR

  INTO CORRESPONDING FIELDS OF TABLE it_MAIN

  WHERE KNA1~KUNNR IN C_Code.

   

  MOVE: it_MAIN-KUNNR  TO it_output-KUNNR.

        it_MAIN-NAME1 TO it_output-NAME1,

        it_MAIN-NAME2 TO it_output-NAME2,

        it_MAIN-STRAS TO it_output-STRAS,

        it_MAIN-ZTERM TO it_output-ZTERM,

        it_MAIN-VKORG TO it_output-VKORG,

        it_MAIN-VTWEG TO it_output-VTWEG,

        it_MAIN-SPART TO it_output-SPART.

ENDFORM.                    " get_proj

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,424

Hi,

You would have to move the values using MOVE-CORRESPONDING or a LOOP and APPEND the values to IT_OUTPUT as shown below.

  MOVE-CORRESPONDING it_MAIN[] TO it_output[].

OR

*LOOP AT IT_MAIN.

*MOVE :  it_MAIN-KUNNR TO it_output-KUNNR,

*        it_MAIN-NAME1 TO it_output-NAME1,

*        it_MAIN-NAME2 TO it_output-NAME2,

*        it_MAIN-STRAS TO it_output-STRAS,

*        it_MAIN-ZTERM TO it_output-ZTERM,

*        it_MAIN-VKORG TO it_output-VKORG,

*        it_MAIN-VTWEG TO it_output-VTWEG,

*        it_MAIN-SPART TO it_output-SPART.

*APPEND IT_OUTPUT.

*ENDLOOP.

9 REPLIES 9
Read only

Former Member
0 Likes
1,424

Hi Howard,

     Good Day!

     You might wanna declare another internal table instead of using "IT_OUTPUT" since you cannot pass the content of the internal table "IT_MAIN" to a field object(table structure) which is "IT_OUTPUT". You can also use internal table "IT_MAIN" for your FM "REUSE_ALV_GRID_DISPLAY".

Please <removed by moderator> and follow me if found useful.

Best Regards,

Charlie

Message was edited by: Manish Kumar

Read only

0 Likes
1,424

Hi Howard,

You can use assignment to achieve this.

        it_MAIN-KUNNR  = it_output-KUNNR.

        it_MAIN-NAME1  = it_output-NAME1.

        it_MAIN-NAME2  = it_output-NAME2.

        it_MAIN-STRAS  =  it_output-STRAS.

        it_MAIN-ZTERM  = it_output-ZTERM.

        it_MAIN-VKORG  = it_output-VKORG.

        it_MAIN-VTWEG  = it_output-VTWEG.

        it_MAIN-SPART   = it_output-SPART.

Regards,

FB

Read only

0 Likes
1,424

Also, as i have noticed on the coding, you already ended your chained statement with a period. Please see image below.

  MOVE: it_MAIN-KUNNR  TO it_output-KUNNR.    <---- (Do not end with a period yet, kindly use comma(,) )

        it_MAIN-NAME1 TO it_output-NAME1,

        it_MAIN-NAME2 TO it_output-NAME2,

        it_MAIN-STRAS TO it_output-STRAS,

        it_MAIN-ZTERM TO it_output-ZTERM,

        it_MAIN-VKORG TO it_output-VKORG,

        it_MAIN-VTWEG TO it_output-VTWEG,

        it_MAIN-SPART TO it_output-SPART.

Read only

Former Member
0 Likes
1,424

Hi,

you have a SELECT ...,. INTO TABLE IT_MAIN.

But when you move the data, your header line of IT_MAIN is empty.

You need a LOOP AT IT_MAIN or a READ TABLE IT_MAIN before you can move the data.

Regards,

Klaus

Read only

nikolayevstigneev
Contributor
0 Likes
1,424

Hi, Howard!

In ABAP 7.4 it is possible to do MOVE-CORRESPONDING for internal tables.

If you have a lower version you can use method CL_RECA_DATA_SERVICES=>MOVE_CORRESPONDING_TABLE.

It does the same: move-corresponding from one itab to another.

Read only

0 Likes
1,424

Hi,

You would have to move the values using MOVE-CORRESPONDING or a LOOP and APPEND the values to IT_OUTPUT as shown below.

TABLES: KNA1,KNVV,TVKOT.

*--------------------------------------------------------------*

*Data Declaration

*--------------------------------------------------------------*

TYPE-POOLS: slis.                   "ALV Global types

DATA:

  BEGIN OF it_output OCCURS 0,

        KUNNR TYPE KNA1-KUNNR,

        NAME1 TYPE KNA1-NAME1,

        NAME2 TYPE KNA1-NAME2,

        STRAS TYPE KNA1-STRAS,

        ZTERM TYPE KNVV-ZTERM,

        VKORG TYPE KNVV-VKORG,

        VTWEG TYPE KNVV-VTWEG,

        SPART TYPE KNVV-SPART,

  END OF it_output,

  gt_list_top_of_page TYPE slis_t_listheader,"to print header/footer

  gt_list_btm_of_page TYPE slis_t_listheader,"to print header/footer

  gt_events           TYPE slis_t_event,

  gs_layout           TYPE slis_layout_alv,"column width optimize, alternate colors, subtotal text...

  gt_fieldcat         TYPE slis_t_fieldcat_alv."field catalog for internal table

*--------------------------------------------------------------*

*Selection-Screen

*--------------------------------------------------------------*

SELECT-OPTIONS: C_Code FOR KNA1-KUNNR.

AT SELECTION-SCREEN.

IF sy-ucomm = 'ONLI'.

  PERFORM validate_mandatory.

  ENDIF.

*----------------------------------------------------------------------*

* Start of selection

*----------------------------------------------------------------------*

START-OF-SELECTION.

*-----------------*

  PERFORM progress USING 20 'Retrieving Data'.

  PERFORM get_data.

*----------------------------------------------------------------------*

* End of selection

*----------------------------------------------------------------------*

END-OF-SELECTION.

*---------------*

  PERFORM progress USING 60 'Preparing Data'.

  PERFORM build."Build the fields for ALV display

  PERFORM eventtab_build CHANGING gt_events.

  PERFORM comment_build  CHANGING gt_list_top_of_page.

  PERFORM comment_build_btm  CHANGING gt_list_btm_of_page.

  PERFORM call_alv.

*&---------------------------------------------------------------------*

*&      Form  validate_field

*&---------------------------------------------------------------------*

*----------------------------------------------------------------------*

FORM validate_mandatory .

    IF C_Code[] IS INITIAL.

      MESSAGE E014(ZMSG) WITH 'Please insert customer code.'.

    ENDIF.

ENDFORM.                    " validate_field

*&---------------------------------------------------------------------*

*---------------------------------------------------------------------*

*       FORM comment_build_btm

*---------------------------------------------------------------------*

* Summary of the list for ALV display

*---------------------------------------------------------------------*

FORM comment_build_btm CHANGING gt_btm_of_page TYPE slis_t_listheader.

  DATA: gs_line TYPE slis_listheader.

  CLEAR gs_line.

  gs_line-typ = 'S'.

  gs_line-info = 'End of report'.

  APPEND gs_line TO gt_btm_of_page.

ENDFORM.                    "comment_build_btm

*----------------------------------------------------------------------*

*       FORM call_alv

*----------------------------------------------------------------------*

*       Display of ALV screen

*----------------------------------------------------------------------*

FORM call_alv.

  PERFORM progress USING 80 'Generating ALV Grid Display'.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

      i_callback_program = sy-cprog

      is_layout          = gs_layout

      it_fieldcat        = gt_fieldcat[]

      i_save             = 'A'

      it_events          = gt_events[]

    TABLES

      t_outtab           = it_output

    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 comment_build

*---------------------------------------------------------------------*

* Header of the page for ALV display using information from selection

*---------------------------------------------------------------------*

FORM comment_build CHANGING gt_top_of_page TYPE slis_t_listheader.

  DATA: gs_line TYPE slis_listheader.

  DATA: l_datum(10)  TYPE c,          "Date

       l_datumh(10) TYPE c,          "Date High

      l_DBCNT(10)  TYPE c,      "Record Count

        l_uzeit(8)   TYPE c,          "Time

        l_psphi      LIKE prps-posid, "Project Code

       l_psphih     LIKE prps-posid. "Project Code High

  CLEAR gs_line.

  gs_line-typ = 'H'.

  gs_line-info = 'Assignment 3'.

  APPEND gs_line TO gt_list_top_of_page.

  IF NOT C_Code IS INITIAL.

    CLEAR gs_line.

    gs_line-typ = 'S'.

    gs_line-key = 'Customer Code: '.

    IF NOT C_Code-high IS INITIAL.

      CONCATENATE C_Code-low 'to' C_Code-high INTO gs_line-info

        SEPARATED BY space.

    ELSE.

      gs_line-info = C_Code-low.

    ENDIF.

    IF NOT gs_line-info IS INITIAL.

      APPEND gs_line TO gt_list_top_of_page.

    ENDIF.

  ENDIF.

  CLEAR gs_line.

  gs_line-typ = 'A'.

  CONCATENATE 'Client/System/User' ':' sy-mandt '/' sy-sysid

  '/' sy-uname

    INTO gs_line-info SEPARATED BY space.

  APPEND gs_line TO gt_list_top_of_page.

  CLEAR gs_line.

  gs_line-typ = 'A'.

  WRITE: sy-datlo TO l_datum,

         sy-timlo TO l_uzeit.

  CONCATENATE 'Date' ':' l_datum

  INTO gs_line-info SEPARATED BY space.

  APPEND gs_line TO gt_list_top_of_page.

  CONCATENATE 'Time' ':' l_uzeit

  INTO gs_line-info SEPARATED BY space.

  APPEND gs_line TO gt_list_top_of_page.

  CLEAR gs_line .

  WRITE: SY-DBCNT TO l_DBCNT.

  IF L_DBCNT <> 0 .

    gs_line-typ = 'A'.

    CONCATENATE 'Number of records found = ' l_DBCNT

    INTO gs_line-info SEPARATED BY space.

    ELSE .

     gs_line-typ = 'A'.

     gs_line-info = 'No records found, please enter a valid customer code'.

  ENDIF .

  APPEND gs_line TO gt_list_top_of_page.

ENDFORM.                    "comment_build

*---------------------------------------------------------------------*

*       FORM eventtab_build

*---------------------------------------------------------------------*

*       Build event for ALV Display

*---------------------------------------------------------------------*

FORM eventtab_build CHANGING lt_events TYPE slis_t_event.

  CONSTANTS:

  gc_formname_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.

  DATA: ls_event TYPE slis_alv_event.

  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    EXPORTING

      i_list_type     = 0

    IMPORTING

      et_events       = lt_events

    EXCEPTIONS

      list_type_wrong = 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.

  READ TABLE lt_events WITH KEY name =  slis_ev_top_of_page

                           INTO ls_event.

  IF sy-subrc = 0.

    MOVE gc_formname_top_of_page TO ls_event-form.

    APPEND ls_event TO lt_events.

  ENDIF.

  clear ls_event.

  ls_event-name = 'END_OF_LIST'.

  ls_event-form = 'END_OF_REPORT'.

  APPEND ls_event TO lt_events.

ENDFORM.                    "eventtab_build

*---------------------------------------------------------------------*

*       FORM top_of_page

*---------------------------------------------------------------------*

*       Top of the page for ALV display

*---------------------------------------------------------------------*

FORM top_of_page.

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

      it_list_commentary = gt_list_top_of_page

      i_logo             = 'SSG_LOGO'.

ENDFORM.                    "top_of_page

*&---------------------------------------------------------------------*

*&      Form  end_of_report

*&---------------------------------------------------------------------*

*       Write summary before exit

*----------------------------------------------------------------------*

FORM end_of_report .

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

      it_list_commentary = gt_list_btm_of_page.

ENDFORM.

*---------------------------------------------------------------------*

*       FORM build                                                    *

*---------------------------------------------------------------------*

*       Build the fields for ALV display

*---------------------------------------------------------------------*

FORM build.

DATA: fieldcat_ln TYPE slis_fieldcat_alv.

  DEFINE m_fieldcat.

    add 1 to fieldcat_ln-col_pos.

    clear fieldcat_ln.

    fieldcat_ln-fieldname   = &1.

    fieldcat_ln-tabname     = 'IT_OUTPUT'.

    fieldcat_ln-do_sum      = &2.

    fieldcat_ln-cfieldname  = &3.

    fieldcat_ln-no_out      = &4.

    fieldcat_ln-seltext_m   = &5.

    fieldcat_ln-outputlen   = &6.

    append fieldcat_ln to gt_fieldcat.

  END-OF-DEFINITION.

  m_fieldcat 'KUNNR' '' '' ' '    'Customer Code' ''.

  m_fieldcat 'NAME1' '' '' ' '    'Customer Name 1' ''.

  m_fieldcat 'NAME2' '' '' ' '    'Customer Name 2' ''.

  m_fieldcat 'STRAS' '' '' ' '    'Customer Address' ''.

  m_fieldcat 'ZTERM' '' '' ' '    'Payment Term' ''.

  m_fieldcat 'VKORG' '' '' ' '    'Sales Organization' ''.

  m_fieldcat 'VTWEG' '' '' ' '    'Distribution Channel' ''.

  m_fieldcat 'SPART' '' '' ' '    'Division' ''.

ENDFORM.                    "build

*&---------------------------------------------------------------------*

*&      Form  progress

*&---------------------------------------------------------------------*

*       Display Progress bar

*----------------------------------------------------------------------*

FORM progress USING    per

                       text.

  CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

    EXPORTING

      percentage = per

      text       = text.

ENDFORM.                    " progress

*&---------------------------------------------------------------------*

*&      Form  get_proj

*&---------------------------------------------------------------------*

*       Get proj

*----------------------------------------------------------------------*

FORM get_data.

  TYPES:

      BEGIN OF ity_MAIN,

        KUNNR TYPE KNA1-KUNNR,

        NAME1 TYPE KNA1-NAME1,

        NAME2 TYPE KNA1-NAME2,

        STRAS TYPE KNA1-STRAS,

        ZTERM TYPE KNVV-ZTERM,

        VKORG TYPE KNVV-VKORG,

        VTWEG TYPE KNVV-VTWEG,

        SPART TYPE KNVV-SPART,

      END OF ity_MAIN.

DATA: it_MAIN TYPE STANDARD TABLE OF ity_MAIN WITH HEADER LINE.

  SELECT KNA1~KUNNR KNA1~NAME1 KNA1~NAME2 KNA1~STRAS KNVV~ZTERM KNVV~VKORG KNVV~VTWEG KNVV~SPART

  FROM KNA1 INNER JOIN KNVV

  ON KNA1~KUNNR = KNVV~KUNNR

  INTO CORRESPONDING FIELDS OF TABLE it_MAIN

  WHERE KNA1~KUNNR IN C_Code.

  MOVE-CORRESPONDING it_MAIN[] TO it_output[].

*LOOP AT IT_MAIN.

*MOVE :  it_MAIN-KUNNR TO it_output-KUNNR,

*        it_MAIN-NAME1 TO it_output-NAME1,

*         it_MAIN-NAME2 TO it_output-NAME2,

*        it_MAIN-STRAS TO it_output-STRAS,

*        it_MAIN-ZTERM TO it_output-ZTERM,

*        it_MAIN-VKORG TO it_output-VKORG,

*        it_MAIN-VTWEG TO it_output-VTWEG,

*        it_MAIN-SPART TO it_output-SPART.

*APPEND IT_OUTPUT.

*ENDLOOP.

ENDFORM.

Read only

Former Member
0 Likes
1,425

Hi,

You would have to move the values using MOVE-CORRESPONDING or a LOOP and APPEND the values to IT_OUTPUT as shown below.

  MOVE-CORRESPONDING it_MAIN[] TO it_output[].

OR

*LOOP AT IT_MAIN.

*MOVE :  it_MAIN-KUNNR TO it_output-KUNNR,

*        it_MAIN-NAME1 TO it_output-NAME1,

*        it_MAIN-NAME2 TO it_output-NAME2,

*        it_MAIN-STRAS TO it_output-STRAS,

*        it_MAIN-ZTERM TO it_output-ZTERM,

*        it_MAIN-VKORG TO it_output-VKORG,

*        it_MAIN-VTWEG TO it_output-VTWEG,

*        it_MAIN-SPART TO it_output-SPART.

*APPEND IT_OUTPUT.

*ENDLOOP.

Read only

0 Likes
1,424

Hi,

You are selecting data into table and trying to move data from Work Area to Work Area.

with out Looping or Reading data from internal table how the data will pass to Work area.

If you want to move data from Work area to Work area you can use

MOVE-CORRESPONDING it_MAIN to it_output.

If you want to move from Internal table to Internal table.

  it_output[] = it_MAIN[]..

*  MOVE: it_MAIN-KUNNR  TO it_output-KUNNR,   

*  it_MAIN-NAME1 TO it_output-NAME1,

*  it_MAIN-NAME2 TO it_output-NAME2,

*  it_MAIN-STRAS TO it_output-STRAS,

*  it_MAIN-ZTERM TO it_output-ZTERM,

*  it_MAIN-VKORG TO it_output-VKORG,

*  it_MAIN-VTWEG TO it_output-VTWEG,

*  it_MAIN-SPART TO it_output-SPART.

  it_output[] = it_MAIN[].

MOVE-CORRESPONDING it_MAIN to it_output.

Thanks & Regards,

Bhargav.

Read only

0 Likes
1,424

Hi,

You will not face any issue using statement it_output[] = it_MAIN[] as long as both the tables are maintained in the same format, but in future if any of the table structure changes it will throw an error.

also you may face the same issue if you use.

LOOP AT IT_MAIN.

MOVE it_MAIN to it_output.

ENDLOOP.


Hence it is advisable to use

MOVE-CORRESPONDING it_MAIN[] TO it_output[].


OR


LOOP AT IT_MAIN.

MOVE :  it_MAIN-KUNNR TO it_output-KUNNR,

        it_MAIN-NAME1 TO it_output-NAME1,

        it_MAIN-NAME2 TO it_output-NAME2,

        it_MAIN-STRAS TO it_output-STRAS,

        it_MAIN-ZTERM TO it_output-ZTERM,

        it_MAIN-VKORG TO it_output-VKORG,

        it_MAIN-VTWEG TO it_output-VTWEG,

        it_MAIN-SPART TO it_output-SPART.

APPEND IT_OUTPUT.

ENDLOOP.