Outgoing data based on table name

Source: Internet
Author: User

function zbu_rfc_103.
*"----------------------------------------------------------------------
* "*" Local Interface:
* "Importing
* "VALUE (Gjahr) TYPE Gjahr
* "VALUE (monat_begin) TYPE Monat
* "VALUE (monat_end) TYPE Monat
* "VALUE (ZHSXM) TYPE Zhsxm OPTIONAL
* "VALUE (zsrprctr) TYPE zsrprctr OPTIONAL
* "VALUE (zzcprctr) TYPE zzcprctr OPTIONAL
* "VALUE (ztable) TYPE tabname
* "Exporting
* "VALUE (ERROR) TYPE CHAR1
* "VALUE (MESSAGE) TYPE CHAR40
* "TABLES
* "It_struc STRUCTURE Zit_struc OPTIONAL
* "It_data STRUCTURE zbukcde_cells OPTIONAL
*"----------------------------------------------------------------------

SELECT *
From dd03l
into correspondingFieldsOfTable It_struc
where tabname= Ztable.

If Sy-subrcNe0.

Error=X.
Message=' Table name does not exist '.

Else.
"Defines the structure of the inner table

Define Create_structure.

Wa_structure-fieldname= &1.The column name

Wa_structure-col_pos= &2."Indicates the first few columns---

Wa_structure-inttype= &3.The data type

Wa_structure-intlen= &4."Length

APPEND wa_structureTo It_structure.

End-of-definition.

LoopAt It_struc.
Create_structure It_struc-fieldname It_struc-Position It_struc-inttype It_struc-intlen.
Endloop.

"In accordance with the defined inner table structure, an inner table is generated
PagerMethod Cl_alv_table_create=>create_dynamic_table
Exporting
It_fieldcatalog= It_structure
Importing
Ep_table= Dy_table.

Assign Dy_table->*To <dyn_table>.

The table type pointer <dyn_table> points to the contents of the data object.
Data l_strType string.
"Assembly conditions

L_str=' Gjahr = Gjahr and Monat between Monat_begin and Monat_end '.

If ZHSXMNe‘‘.
Concatenate l_str' and ZHSXM = Zhsxm 'Into L_str.
endif.

If zsrprctrNe‘‘.
Concatenate l_str' and zsrprctr = Zsrprctr 'Into L_str.
endif.

If zzcprctrNe‘‘.
Concatenate l_str' and zzcprctr = Zzcprctr 'Into L_str.
endif.

"Write to dynamic inner table
SELECT *into correspondingFieldsOfTable <dyn_table>
From(ztable)
where(L_str).

"Take a number from the dynamic inner table and write to the screen

Data: Wa_new_lineTypeRefToData.

CreateData wa_new_lineLikeLineof <dyn_table>.

* Create a data object with the same structure as the dynamic inner table, and the data object is a structure

Assign Wa_new_line->*To <dyn_wa>."Use the <dyn_wa> pointer to point to the structure

Data I_rowType Kcd_ex_row_nValue0.

LoopAt <dyn_table>Into <dyn_wa>.

I_row= I_row +1.

LoopAt It_structureInto Wa_structure.

AssignComponent Wa_structure-fieldnameOfStructure <dyn_wa>

To <dyn_field>.

* with pointer <DYN_FIELD> to a field in Workspace <DYN_WA>, the field is named Wa_structure-fieldname.

It_data-fieldname= Wa_structure-fieldname.
It_data-row= I_row.
It_data-col= wa_structure-col_pos         it_data-value < Span class= "L0S55" >= <dyn_field>         condense it_data- value         append it_data
      endloop
    endloop
  endif
endfunction

Outgoing data by table name

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.