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: 

Accessing an included structure .

Former Member
0 Kudos

I have an internal table that has an included structure. This structure has 45 fields of the same type. I need to get a specific entry from this table and then read, and eventually modify, a field in the included structure. I assumed I could read it like the code below but it gives me a syntax error. wa_detail is a work area and days is the structure with index_days being the index.

FORM updatedaystructure .

DATA: temp_quantity TYPE i.

temp_quantity = wa_detail-days INDEX index_day.

ENDFORM.

Regards,

Davis

7 REPLIES 7

Former Member
0 Kudos

Try:


FORM updatedaystructure .
DATA: temp_quantity TYPE i.
Read table detail into wa_details index index_day.
temp_quantity = wa_detail-days.

ENDFORM

You have to replace "detail" with the name of your actual table.

Rob

Message was edited by:

Rob Burbank

0 Kudos

Rob, thanks for the reply. I need the index to act on the structure (days) not the table. This is why I'm having trouble. I may be wrong but I believe your example is having the index to act on the table not the structure

EDIT: The syntax error I get is "Arithmetic operations are only intended for operands that can be converted to numbers."

Regards,

Davis

Message was edited by:

Davis

0 Kudos

Yes - that's right. I think you can probably do what you want using field symbols.

Rob

0 Kudos

I've tried several things, the following be the best in my uninformed opinion, but I keep getting the same syntax error.

FORM updatedaystructure .
  DATA: temp_quantity TYPE i,
        temp_day TYPE i.
  FIELD-SYMBOLS <field> TYPE z45days.
  ASSIGN wa_detail-days TO <field> CASTING..

  temp_day = <field> INDEX index_day.

ENDFORM. 

Regards,

Davis

Message was edited by:

Davis

Former Member
0 Kudos

I have tried the following and it tells me that wa_details-days is not defined but it is. All I need to do is add a number to the entry in wa_detail-days (index index_day).

wa_detail-days index index_day = wa_detail-days index index_day + wa_detail_temp-erfmg.

Any help would be appreciated!

Regards,

Davis

0 Kudos

Hi,

Try using this code

***********************************************************************************************

***********************************************************************************************

FORM updatedaystructure .

DATA: temp_quantity TYPE i,
         wa_days like days.      "this is type of structure DAYS

FIELD-SYMBOLS: <field> TYPE z45days. " type of "field in structure DAYS"

**index1 is used to read table entry where you want to update DAYS
Read table detail into wa_details index index1 .  ( this is not index_days)  

wa_days = wa_index-days.

ASSING COMPONENT index_days OF STRUCTURE wa_days TO <field>.
ENDFORM

***********************************************************************************************

***********************************************************************************************

This way you will get the content of field in DAYS.

If you can give me the structure of your table, structure of DAYS ( give me the field type since all fields are same) and what exactly you are trying to achieve, i might be able to help you.

Regards,

RS

Message was edited by:

RS

Message was edited by:

RS

0 Kudos

RS, thanks for the reply. Below is the structure of the table.

TYPES: BEGIN OF ty_detail,
          matnr TYPE mseg-matnr,  "Mat. #
          bwart TYPE mseg-bwart,  "Movement Type
          erfme TYPE mseg-erfme,  "Unit of entry
          erfmg TYPE mseg-erfmg,  "Quantity in unit of entry
          werks TYPE mseg-werks,  "Plant #
          maktl TYPE mara-matkl,  "Mat Group
          mtart TYPE mara-mtart,  "Mat Type
          maktx TYPE makt-maktx,  "Mat Description
          days TYPE z45days,
      END OF ty_detail.

Days just holds 45 fields of type QUAN. Ultimately I am trying to add an integer to a component in the structure (keep a running tally). When I enter this form I already have the work area for the table loaded with the right entry (wa_detail) and I also have the index of the work area (index_table) (I stored the index in case I couldn't use the work area). I also have the index of the needed component in the structure (the component that needs to be updated) stored in index_day.

Any help you can give me would be more than appreciated!

Regards,

Davis

Message was edited by:

Davis