cancel
Showing results for 
Search instead for 
Did you mean: 

Only single record is appearing on Script form

Former Member
0 Kudos

DEAR ABAP GURUS N EXPERTS,

I am new to ABAP and require to design a form for printing the Quality parameters for the PO Material. For this I am using SAP Script. as follows:

data: begin of wa,

ebeln like ekko-ebeln, "PO No.

bukrs like ekko-bukrs,

lifnr like ekko-lifnr, "Vendor Code

name1 like lfa1-name1, "Vendor name

txz01 like ekpo-txz01, "Material Text

matnr like ekpo-matnr, "Material Code

plnnr like mapl-plnnr, "QC Group

end of wa,

itab like table of wa.

data: begin of wa1,

plnnr like mapl-plnnr, "GROUP

merknr like plmk-merknr, "Characterisitc ID

verwmerkm like plmk-verwmerkm, "Master Inspection Characteristics

kurztext like plmk-kurztext, "Short Text

masseinhsw like plmk-masseinhsw, "UOM

sollwert like plmk-sollwert, "Target Value

toleranzob like plmk-toleranzob, " Upper Limit

toleranzun like plmk-toleranzun, "Lower Limit

end of wa1,

itab1 like table of wa1.

*data:t_po type standard table of ty_po with header line initial size 1.

*data:w_po type ty_po.

data:stdval type p decimals 2.

data:minval type p decimals 2.

data:maxval type p decimals 2.

data:stdval2 type p decimals 2.

data:minval2 type p decimals 2.

data:maxval2 type p decimals 2.

data:paraid like plmk-merknr.

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

initialization.

  • parameters:PLNNR type PLNNR.

parameters:ebeln type ebeln.

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

start-of-selection.

select

ekpo~txz01

ekpo~matnr

ekko~lifnr

lfa1~name1

  • MAPL~PLNNR

into corresponding fields of table itab from ekpo

inner join ekko on ekkoebeln = ekpoebeln

inner join lfa1 on lfa1lifnr = ekkolifnr

  • inner join mapl on maplmatnr = ekpomatnr

where

ekpo~ebeln = ebeln and

ekpo~loekz <> 'L' and

ekkobstyp = 'F' and ekkobsart = 'NB'.

loop at itab into wa.

select

mapl~plnnr

plmk~merknr

plmk~verwmerkm

plmk~kurztext

plmk~masseinhsw

plmk~sollwert as sollwert

plmk~toleranzob as toleranzob

plmk~toleranzun as toleranzun

into corresponding fields of table itab1 from mapl

inner join plmk on plmkplnnr = maplplnnr

where

mapl~matnr = wa-matnr and

plmk~plnty = 'Q'

  • and PLMK~PLNNR = wa-PLNNR

and plmksteuerkz = 'XX XXX=X .X' and plmkloekz <> 'X'

order by plmk~merknr.

loop at itab1 into wa1.

paraid = wa1-merknr.

stdval = wa1-sollwert.

maxval = wa1-toleranzob.

minval = wa1-toleranzun.

endloop.

endloop.

****************START OF SCRIPT*********************************

call function 'OPEN_FORM'

exporting

form = 'Z_2008_PO-T'

language = sy-langu.

if sy-subrc = 0.

endif.

****************HEADER********************

call function 'WRITE_FORM'

exporting

element = space

type = 'BODY'

function = 'DELETE'

window = 'MAIN'.

if sy-subrc <> 0.

endif.

*********************CLOSE SCRIPT FORM*********************

call function 'CLOSE_FORM'

.

if sy-subrc <> 0.

endif.

On Form I have mentioned:

&wa1-merknr(4)& &wa1-KURZTEXT(25)& &stdval(5)& &maxval(5)&

&minval(5)&

Please suggest where am I wrong?

With thanks.

DSC

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Dear All,

I have tried with calling WRITE FORM FUNCTION MODULE Wtih in loop. But is is still showing one record.

Please tell us what is the problem.

IF ANY ONE HAVE AN IDEA. PLEASE MODIFY MY CODES (GIVEN ABOVE, on my first post).

With thanks,

DSC

former_member230486
Contributor
0 Kudos

Hi Devendra,

You have to write write_form function module inside the loop,so that you can get the records.

former_member212854
Participant
0 Kudos

Also you could use FOR ALL ENTRIES statement instead of calling select statement inside a loop.

for example say the internal table you looping have 100 records and you have a select statement inside the loop then for every single record system will hit the database, it means in our case it will hit 100 times. Instead of that we could use FOR ALL ENTRIES statement to hit the database just once.

former_member212854
Participant
0 Kudos

Firstly, SELECT statement is not recommended inside loop endlloop. Its performance intensive and not a good practice.

coming to your question, please call the function module write_form in a loop to print all the items to the form.

Edited by: Ashwin Kumar Chitram on Oct 3, 2011 6:24 PM

Edited by: Ashwin Kumar Chitram on Oct 3, 2011 6:26 PM