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

Creating Internal table in SQ02

Former Member
0 Likes
2,779

Hi,

I'm trying to write code in Extras under record processing in SQ02.

My question is : I have 2 tables.

1st table : VBAP having all the fields.

2nd table: Ztable which has vbeln, posnr, qty

so the join condition would be vbeln & posnr.

I have a situation like in VBAP,only 1 record

VBELN POSNR KWMENG

500000 100 150

In ZTable: 2 records

VBELN POSNR Qty

500000 100 150

500000 100 150

Now I have to check for qty mismatch vbap-kwmeng <> ztable-qty where vbap-vbeln = ztable-vbeln & vbap-posnr = ztable-posnr.

since the above qty's doesn't match, I need to print both the records(SUM) from Ztable or print as 2 records

My sample output should be:

vbeln posnr vbap-kwmeng ztable-qty

500000 100 150 300(sum of 2 records)

or

vbeln posnr vbap-kwmeng ztable-qty

500000 100 150 150

500000 100 150

how to print 2 lines or sum of qty in 1 line.

I'm thinking if I can create an internal table where I can pass the records to that table, and print that in the output.

But when I try to create table, it asks for structure like SAP table... is there a way to create internal table and print the output from that internal table. we can create internal table under data declaration.... but how to print that?????????

Thanks.

1 ACCEPTED SOLUTION
Read only

former_member181966
Active Contributor
0 Likes
1,682

In Sq02 , Just declare one table i.e. VBAP . After creating that table create local field , select the record from Ztable based upon the key Vblen ? Right.. and SUM the Qty and finally declare this field in SQ03 and you’ll be able to see the output . No need to declare an ITAB ..

Pl award the points if this post help you ...

If you still have any doubts/question let me know …

Thanks

Hi,

I'm trying to write code in Extras under record processing in SQ02.

My question is : I have 2 tables.

1st table : VBAP having all the fields.

2nd table: Ztable which has vbeln, posnr, qty

so the join condition would be vbeln & posnr.

I have a situation like in VBAP,only 1 record

VBELN POSNR KWMENG

500000 100 150

In ZTable: 2 records

VBELN POSNR Qty

500000 100 150

500000 100 150

Now I have to check for qty mismatch vbap-kwmeng <> ztable-qty where vbap-vbeln = ztable-vbeln & vbap-posnr = ztable-posnr.

since the above qty's doesn't match, I need to print both the records(SUM) from Ztable or print as 2 records

My sample output should be:

vbeln posnr vbap-kwmeng ztable-qty

500000 100 150 300(sum of 2 records)

or

vbeln posnr vbap-kwmeng ztable-qty

500000 100 150 150

500000 100 150

how to print 2 lines or sum of qty in 1 line.

I'm thinking if I can create an internal table where I can pass the records to that table, and print that in the output.

But when I try to create table, it asks for structure like SAP table... is there a way to create internal table and print the output from that internal table. we can create internal table under data declaration.... but how to print that?????????

Thanks.

9 REPLIES 9
Read only

former_member181966
Active Contributor
0 Likes
1,683

In Sq02 , Just declare one table i.e. VBAP . After creating that table create local field , select the record from Ztable based upon the key Vblen ? Right.. and SUM the Qty and finally declare this field in SQ03 and you’ll be able to see the output . No need to declare an ITAB ..

Pl award the points if this post help you ...

If you still have any doubts/question let me know …

Thanks

Read only

0 Likes
1,682

Hi Saquid,

I didn't get the point "finally declare the field in SQ03 and you will able to see in the output"

We use SQ03 for creating/maintain user groups? I'm confused? where should we declare this field... and how ...

Thanks.

Read only

0 Likes
1,682

Let me made my self clear. sorry for ambiguity. Once you declare the field in Sq02 by going to EXTRAS-> CREATE NEW FIELD ... new field , code behind the field .. .

Then you need to assign this field to field groups/data felids in Sq02.

After that when you create Query in Sq03 , only you have to select it in SQ03 , so you can see in output.

For more clear understanding how to declare fields etc ..

check:

http://www.sappoint.com/abap/ab4query.pdf

Thanks

Read only

0 Likes
1,682

You mean SQ01.

Let me try and get back to you. Thanks for the idea.

Read only

0 Likes
1,682

Hi,

I tried the suggestion. its giving syntax error for select statement.

steps:

1. declare single table while creating Sq02.

2. declare variable to hold ztable qty. using extras(additional field)

3. trying to get all records in ztable which match vbap, and sum up the qty of ztable...

when I do select in records processing, its thorwing syntax error, " where condition"

I have declared i_kwmeng under data.

select kwmeng

into table i_kwmeng

where vbeln_va = vbap-vbeln and

posnr_va = vbap-posnr.

loop at i_kwmeng.

v_qty = i_kwmeng + v_qty.

endloop

I don't know where I'm doing mistake... or is it not possible to do a select statement using where condition... if we can in which coding section we should do?

Thanks.

Read only

0 Likes
1,682

I'm sorry....

I did a mistake

I haven't given from condition in select

sorry!!

Read only

0 Likes
1,682

Why dont`t you do something like ...

<b>Define single field as qty like vbap-kwmeng.</b>In code ...

<b>Data:total_qty like

clear:total_qty.

select kwmeng

into qty

where vbeln_va = vbap-vbeln and

posnr_va = vbap-posnr.

total_qty = qty + total_qty.

endselect.</b>

it should work ...

Thanks

Read only

0 Likes
1,682

Thank you saquib. It worked using internal table itself...

Read only

0 Likes
1,682

Hi,

I have all my results in an internal table...at the end of selection event. It does not let me output the internal table using the additional records or additional structure. Is there a way I can output an internal table?

Thanks,

ravi.