Application Development 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: 

SMART FORMS: How to declare and append values to an internal table

Former Member
0 Kudos

Does anyone knows how to declare and internal table <i>with header line</i> and the <i>occurs n</i> clause in <b>Smart Forms</b> using the <b>Types</b> statement.

The purpose is for append data to this table and pass it as an output parameter on a code window.

Any suggestion will be welcome.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

( You can do it but without header line. For header line you will need separate work area ( or field symbol ). Just see below is an example )

In the global definition on <b>TYPES</b> tab.

<b>TYPES : BEGIN OF WA_TAB,

FILED1,

FIELD2,

END OF WA_TAB.

TYPES : TAB TYPE STANDARD TABLE OF WA_TAB INITIAL SIZE 0.</b>

On the global definition on <b>Global Data</b> tab

<b>ITAB TYPE TAB

WA TYPE WA_TAB</b>

In your code node -

<b>Importing - WA

Exporting - ITAB</b>( this is just to be able to use WA & ITAB in the code )

<b>A-FIELD1 = 'C'.

APPEND WA TO ITAB. </b>

If you want to use this ITAB in any other code / table or loop node you will have to use the option -> Loop at itab into wa.

Cheers

9 REPLIES 9

Former Member
0 Kudos

Hi,

I don't think you would really required a table like that. You declare a table in the global data with a type. Now if you want to pass this table to the code, you can just specify the table name in the input parameters.

If you have to read this table inside the code, jsut declare a local work area / field symbols of the same structure of the table and you should be able to use the READ statement.

If this does not solve your purpose, could you please give more details.

Regards,

Ravi

Note : If this helps you, please reward points.

0 Kudos

The problem is not declaring the table itself, it is to append data to that table <i>(more than one line)</i> and pass it as an output parameter.

I declared with <b>Types</b> because the table contains fields from diferent tables:

TYPES: BEGIN OF DETAILS,

EBELP TYPE EKPO-EBELP,

EMATN TYPE EKPO-EMATN,

TXZ01 TYPE EBAN-TXZ01,

MSEHT TYPE T006A-MSEHT,

BSMNG TYPE EBAN-BSMNG,

LFDAT TYPE RM06P-LFDAT,

TDTEXT TYPE TTXIT-TDTEXT,

END OF DETAILS.

TYPES: WA_DETAILS TYPE STANDARD TABLE OF DETAILS.

<i>Then in the code window:</i>

Input Parameters: <b>WA_EKPO, WA_EBAN</b>.

Output Parameters: <b>WA_DETAILS</b>.

LOOP AT WA_EKPO.

WA_DETAILS-EBELP = WA_EKPO-EBELP.

WA_DETAILS-EMATN = WA_EKPO-EMATN.

WA_DETAILS-TXZ01 = WA_EBAN-TXZ01.

APPEND WA_DETAILS. <b><i><==This line causes the problem</i></b>

ENDLOOP.

The error <u>["WA_DETAILS" is not an internal table - the "OCCURS n" specification is missing.</u>] appears with this code. Also declaring the table in the <i>Global data</i> triggers the same error. The only way to avoid this error is to declaring the table in the code window with the <b>OCCURS n</b> and <b>WITH HEADER LINE</b> clauses. But when you pass the table as an <i>Output parameter</i> the error <u>[The field "WA_DETAILS" is unknow]</u>. appears.

Any suggestions?

0 Kudos

Hi,

Its creating a problem because the table does not have workarea.

In the code try this.

DATA : Workarea type details.

LOOP AT WA_EKPO.

Workarea-EBELP = WA_EKPO-EBELP.

Workarea-EMATN = WA_EKPO-EMATN.

Workarea-TXZ01 = WA_EBAN-TXZ01.

APPEND Workarea to WA_DETAILS. <==This line causes the

problem

clear workarea.

ENDLOOP.

This should work.

REgards,

Ravi

Note : Please reward points of this helps you.

0 Kudos

Is this line a typo?




<b>TYPES:</b> WA_DETAILS TYPE STANDARD TABLE OF DETAILS.


Shouldn't it be




<b>DATA:</b> WA_DETAILS TYPE STANDARD TABLE OF DETAILS.


Regards,

Rich Heilman

0 Kudos

Does this syntax not work for you?




report zrich_0002.


types: begin of details,
ebelp type ekpo-ebelp,
ematn type ekpo-ematn,
txz01 type eban-txz01,
mseht type t006a-mseht,
bsmng type eban-bsmng,
lfdat type rm06p-lfdat,
tdtext type ttxit-tdtext,
end of details.

data: wa_details type details.
data: it_details type standard table of details.

data: wa_ekpo type ekpo.
data: it_ekpo type table of ekpo.



loop at it_ekpo into wa_ekpo.
  wa_details-ebelp = wa_ekpo-ebelp.
  wa_details-ematn = wa_ekpo-ematn.
  append wa_details to it_ekpo.
endloop.

Regards,

Rich Heilman

0 Kudos

Define types in the types tab.

After that in global definition define your table as

ITAB TYPE TABLE OF DETAILS.

WA_DETAILS TYPE DETAILS.

In the Code window,

put your data in WA_DETAILS

and then

APPEND WA_DETAILS TO ITAB

0 Kudos

You can define the work area in the Global Data tab of global definition as in the example in thread given earlier -

<b>WA TYPE DETAILS</b>

Add this parameter <b>WA</b> to the importing of your code node to be able to use it in the code.

Also WA_DETAILS is type and not a data itself.

You will have to define a golbal data like

<b>ITAB TYPE WA_DETAILS</b>

In the code node you should use ITAB and not WA_DETAILS.

WA-DETAILS is just a type and not a data object which you can use in code.

Cheers

Former Member
0 Kudos

You can define Types by going to Global Definitions and clicking on the TYPES tab.

Here you can define your structure. You can define your work area and internal table in the Global Data by refering to this structure.

You can populate this internal table in the Initialization tab of Global Definitions and use it anywhere in the Smart Form.

Hope this helps.

Regards

Maninder

Former Member
0 Kudos

( You can do it but without header line. For header line you will need separate work area ( or field symbol ). Just see below is an example )

In the global definition on <b>TYPES</b> tab.

<b>TYPES : BEGIN OF WA_TAB,

FILED1,

FIELD2,

END OF WA_TAB.

TYPES : TAB TYPE STANDARD TABLE OF WA_TAB INITIAL SIZE 0.</b>

On the global definition on <b>Global Data</b> tab

<b>ITAB TYPE TAB

WA TYPE WA_TAB</b>

In your code node -

<b>Importing - WA

Exporting - ITAB</b>( this is just to be able to use WA & ITAB in the code )

<b>A-FIELD1 = 'C'.

APPEND WA TO ITAB. </b>

If you want to use this ITAB in any other code / table or loop node you will have to use the option -> Loop at itab into wa.

Cheers