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

urgent: selection screen

Former Member
0 Likes
1,514

hi,

i have this report to make , in which when the user enters the first four char of the field mara-normt, then i should select all the materials belonging to normt and add their quantity and return. i.e. if the user enters first four digits e.g 'fort' then i should calculate all the material's quantity (mard-labst)which start with 'fort' and give the total quantity. can anyone give me some code for this.

bye

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,492

Hi indira,

1. Simple.

2.

REPORT zam_temp169 .

DATA : labst LIKE mard-labst.

PARAMETERS : normt LIKE mara-normt.

DATA : var(18) TYPE c.

CONCATENATE '%' normt '%' INTO var.

SELECT SUM( labst ) AS labst FROM mara AS a

INNER JOIN mard AS b

ON amatnr = bmatnr

INTO labst

WHERE a~normt LIKE var.

BREAK-POINT.

WRITE 😕 labst.

regards,

amit m.

hi,

i have this report to make , in which when the user enters the first four char of the field mara-normt, then i should select all the materials belonging to normt and add their quantity and return. i.e. if the user enters first four digits e.g 'fort' then i should calculate all the material's quantity (mard-labst)which start with 'fort' and give the total quantity. can anyone give me some code for this.

bye

12 REPLIES 12
Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,492

Hi,

data itab type standard table of mara.

data v(20).

parameter p_normt type mara-normt.

start-of-selection.

concatenate p_normt '%' into v.

select * from mara into table itab where normt like v.

Then calculate the total quantiry.Otherwise try using sum(quantity) in select statement with group by.

Kindly reward points by clicking the star on the left of reply,if it helps.

Read only

0 Likes
1,492

Hi,

The user will enter only text(not wildcard say eg.. fort) in the parameter in selection screen.

We are only appending % in our code to fetch the records starting with fort%.

Read only

Former Member
0 Likes
1,492

hi

I hope the user will give a wild card while he is inputting values in selection screen. i.e., he would be entering 'fort*' for selecting all values starting with 'fort' in that case use

REPLACE '*' WITH '%' INTO <b>p_normt</b>.

select mard-labst

from mara

into table itab

where normt like p_normt.

now after capturing all the values you can sum it up.

if the user is just giving first four charecters without a wild card then you add it explicitly.

Regards

Santosh

Read only

Former Member
0 Likes
1,492

hi, thankyou for this, but user will not enter any wild card. so, can you please send me complete code sample.

Read only

Former Member
0 Likes
1,492

HI Indira,

try this one..

DATA : ITAB LIKE TABLE OF MARD WITH HEADER LINE.

SELECT * UP TO 2 ROWS FROM MARD INTO TABLE ITAB

WHERE <field> CP 'FORT*'.

LOOP AT ITAB.

AT LAST.

SUM.

write : / <fields>

ENDLOOP.

if the user enters fort in

parameters : p_field ..

concatenate p_field '*' into p_field.

and then use..

SELECT * UP TO 2 ROWS FROM MARD INTO TABLE ITAB

WHERE <field> CP p_field.

regards

satesh

Read only

Former Member
0 Likes
1,493

Hi indira,

1. Simple.

2.

REPORT zam_temp169 .

DATA : labst LIKE mard-labst.

PARAMETERS : normt LIKE mara-normt.

DATA : var(18) TYPE c.

CONCATENATE '%' normt '%' INTO var.

SELECT SUM( labst ) AS labst FROM mara AS a

INNER JOIN mard AS b

ON amatnr = bmatnr

INTO labst

WHERE a~normt LIKE var.

BREAK-POINT.

WRITE 😕 labst.

regards,

amit m.

Read only

Former Member
0 Likes
1,492

HI indira

tables: mara,mard.

parameters: p_param like mara-normt.

data: total like mard-labst.

data: begin of itab occurs 0,

matnr like mara-matnr,

labst like mard-labst,

end of itab.

concatenate P_param '%' into p_param.

select maramatnr mardlabst into table itab from mara inner join mard on maramatnr = mardmatnr where mara~normt like p_param.

loop at itab.

total = total + itab-labst.

endloop.

write : total.

this code works fine

regards

kishore

Read only

Former Member
0 Likes
1,492

i have tried the code below but im getting all the list of material which are not related to ngort also.

REPORT ztesting NO STANDARD PAGE HEADING .

TABLES: mara,mard.

PARAMETERS: p_param LIKE mara-normt.

DATA: BEGIN OF itab OCCURS 0,

matnr LIKE mara-matnr,

END OF itab.

CONCATENATE p_param '%' INTO p_param.

SELECT mara~matnr INTO TABLE itab FROM mara INNER JOIN mard

ON maramatnr = mardmatnr

WHERE mara~normt LIKE p_param.

LOOP AT itab.

write:/ itab-matnr.

ENDLOOP.

Read only

0 Likes
1,492

hi

Are you getting any Extra records(Materials)? and why is Inner Join used in the select?

More over I am getting only related materials when I Execute your code

Santosh

Read only

Former Member
0 Likes
1,492

i'm not just trying to print the materials which if the user enters first four char of normt field. but its not executing. i dont know, its coming out of the select statement. the following is the code

REPORT ztesting NO STANDARD PAGE HEADING .

TABLES: mara.

PARAMETERS: p_param LIKE mara-normt.

DATA: BEGIN OF itab OCCURS 0,

matnr LIKE mara-matnr,

normt LIKE mara-normt,

END OF itab.

CONCATENATE p_param '%' INTO p_param.

SELECT matnr normt FROM mara INTO itab

WHERE normt = p_param.

APPEND itab.

CLEAR itab.

ENDSELECT.

WRITE:/ 'matnr',25 'normt'.

LOOP AT itab.

WRITE:/ itab-matnr,25 itab-normt.

ENDLOOP.

Read only

0 Likes
1,492

Change select to

SELECT matnr normt FROM mara INTO table itab

WHERE normt like p_param.

Also make sure you are passing value for P_PARAM.

What is the value you see for P_PARAM after concatenating with '%'?

Read only

0 Likes
1,492

Hi Indira,

Just change it this way..

TABLES: mara.

PARAMETERS: p_param LIKE mara-ernam.

DATA: BEGIN OF itab OCCURS 0,

matnr LIKE mara-matnr,

ernam LIKE mara-ernam,

END OF itab.

CONCATENATE p_param '%' INTO p_param.

SELECT matnr ernam

FROM mara

INTO TABLE itab

WHERE ernam like P_param.

WRITE:/ 'matnr',25 'normt'.

LOOP AT itab.

WRITE:/ itab-matnr,25 itab-ernam.

ENDLOOP.