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: 

pass data internal table to additional field in SQ02 via data reading progr

Former Member
0 Kudos
540

In SQ02 I've build a 'data reading program' based on data structure MARA.

Now, in the 'read data into IT_DATA' part, I filled the internal table with data.

This internal table hold (amongst others) a field called ID (type: string).

I can not pass this data via SQ01, only the data with corresponding fields of structure MARA.

What I have:

loop at it_data assigning <struc>.

move-corresponding <struc> to mara.

  • !! the following comment MUST NOT BE CHANGED !!

*<QUERY_BODY>

endloop.

I have created an additional field. However in the coding of this additional field, I can not access it_data.

Also at record processing I can not access my internal table.

Question:

How to pass the data from my internal table to the additional field to be able to output it via SQ01?

Thanks

10 REPLIES 10

Sandra_Rossi
Active Contributor
0 Kudos
86

I think that your data structure must not be MARA but a custom structure containing the fields you need (most from MARA, you may copy all fields if you prefer), including ID field. So you don't need to bother with an additional field.

0 Kudos
86

Not sure what you mean by custom structure.

When setting up the query for data reading, I can choose from database tables or predefined SAP structures.

Do you mean to setup your own structure in SQ02. I know that I can add multiple table in SQ02 but in this way I am restricted to the field which are defined in SAP. I want to be able to use my own defined fields (e.g. my ID field is type string with length 255). I also can build my own structure in the data declaration part of SQ02 and include my ID together with MARA in a new structure. But in this way, it is still not possible to pass the data to SQ01?

thanks,

Marcel

0 Kudos
86

> Not sure what you mean by custom structure.

> \[...\]

> I also can build my own structure in the data declaration part of SQ02 and include my ID together with MARA in a new structure.

I mean exactly what you say about "in a new structure", but it should be in the DDIC instead of the data declaration part of SQ02. So create a custom DDIC structure

> When setting up the query for data reading, I can choose from database tables or predefined SAP structures.

No, it can be any DDIC structure, SAP or customer

> But in this way, it is still not possible to pass the data to SQ01?

Of course we can query the infoset with a custom DDIC structure and with a reading program

0 Kudos
86

Hmmm,

The thing is, I do not have a devellopers key in sap.

For me, ABAP is only open in SQ02, so I am restricted to the SQ02 area.

That's why I was searching for a solution withing SQ02.

I still wonder if it is possible.

- data reading program based on MARA

- additional field

- internal table filled it_data filled with correct data

- pass it to query in SQ01...

thanks

0 Kudos
86

> The thing is, I do not have a devellopers key in sap.

Okay, so your logic is good, you should be able to do it using the integrated program + additional fields.

> That's why I was searching for a solution withing SQ02.

> I still wonder if it is possible.

You don't have to access IT_DATA, as MARA structure is filled. For example, fill your additional field like that, and it's done!


ID = MARA-MTART.

0 Kudos
86

Hi Sandra,

Thanks for your replay (and your patients...).

The method you describe, is referring to mara-mtart, which is part of structure mara.

However, in my example, I have an additional field ID. Below a simple reconstruction of what I am trying to do.

As you can see, I've created id in it_data.

I also created field ID as additonal field in the extra tab, created a new fieldgroup and added my created field into that.

No matter using coding for my additional field or using record processing, I cannot get it_data-id as an output in my query via additional field ID.

thanks

ps: in reality, ID hold the possition and level of my own created logic to determine the possition in a BOM (mast/stko/stpo).

REPORT RSAQDVP_TEMPLATE .

*

----


  • declarations

  • (insert your declarations in this section)

----


data:

begin of ty_temp,

id type string,

end of ty_temp.

types:

begin of ty_data.

include structure mara.

include structure ty_temp.

types: end of ty_data.

data:

MARA type MARA,

it_data type table of ty_data with header line.

field-symbols: <struc> type ty_data.

----


  • selection screen statements

----


  • (define your selection-screen here)

select-options so_matnr for mara-matnr.

  • !! the following comment MUST NOT BE CHANGED !!

*<QUERY_HEAD>

----


  • read data into IT_DATA

----


  • (select your data here into internal table IT_DATA)

it_data-matnr = 'material_xyz'.

it_data-ID = '1.1'.

append it_data.

----


  • output of the data

  • (this section can be left unchanged)

----


loop at it_data assigning <struc>.

move-corresponding <struc> to MARA.

  • !! the following comment MUST NOT BE CHANGED !!

*<QUERY_BODY>

endloop.

0 Kudos
86

you do whatever you want with IT_DATA, it's your local internal table. You don't have to create ID field in it, if you want. What is important is that all structures (MARA fields) and additional fields (ID) are initialized before QUERY_BODY. SAP will transfer them to a new row in the target internal table.


loop at it_data assigning <struc>.
move-corresponding <struc> to MARA.
ID = it_data-ID. "<=== initialize your additional field
* !! the following comment MUST NOT BE CHANGED !!
*<QUERY_BODY>
endloop.

0 Kudos
86

That was my first thought too.

However, doing as you proposed will give the following error:

Field "ID" is unknown. It is neither in one of the specified tables

nor defined by a "DATA" statement.

So my next logic step would be to declare ID in the declaration/data part in SQ02.

However, while running the query via SQ01, I get the following error:

The following syntax error occurred in the program

AQA0CS-CSL======FORUM========= :

""ID" has already been declared."

Error in ABAP application program.

any idea?

thanks.

0 Kudos
86

anyone?

0 Kudos
86

I am not a programmer but ran into the same issue. If you are referencing "ID" in more than one "Extras" (field or table) then make your declaration in the code section "Data" rather than each individual code section for the "Extras".

Edited by: Kevin Mandeville on Jul 6, 2011 3:14 PM

Edited by: Kevin Mandeville on Jul 6, 2011 3:15 PM