can somebody figure out errors in this interac report prog.

Development (ABAP Development WorkBench, ABAP/4 programming)

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

Post Reply
SD_ABAP1
Posts: 5
Joined: Fri Jul 21, 2006 9:42 pm

can somebody figure out errors in this interac report prog.

Post by SD_ABAP1 » Wed Jul 26, 2006 6:23 pm

when I am trying to execute its getting dumped.


*&--------------------------------------------------------------------*
*& Report ZRAJ4 *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*

REPORT ZRAJ4 .
tables: kna1,vbak,vbap,mara.
select-options: cust for kna1-kunnr.
data: begin of itab occurs 0,
kunnr like kna1-kunnr,
name1 like kna1-name1,
end of itab.
data : begin of jtab occurs 0,
vbeln like vbak-vbeln,
netwr like vbak-netwr,
end of jtab.
Data: begin of ktab occurs 0,
posnr like vbap-posnr,
matnr like mara-matnr,
end of ktab.
data: fnam(10), fval(10).
start-of-selection.
select kunnr name1 land1 from kna1 into table itab where kunnr in cust.
loop at itab.
write :/ itab-kunnr hotspot,
itab-name1.
hide itab-kunnr.
endloop.
start-of-selection.
case sy-lsind.
when 1 .
select vbeln netwr from vbak into table jtab where kunnr = itab-kunnr.
loop at jtab.
write: / jtab-vbeln hotspot,
jtab-netwr.
hide jtab-vbeln.
endloop.
when 2.
select vbap~posnr mara~matnr into table ktab from vbap inner join mara
on vbap~matnr = mara~matnr where vbeln = jtab-vbeln.
loop at ktab.
write : / ktab-posnr,
ktab-matnr hotspot.
hide ktab-matnr.
endloop.
when 3.
get cursor field fnam value fval.
set parameter id 'mat' field fval.
call transaction 'mm02' and skip first screen .
endcase.
top-of-page.
write: / 'customer sudheer details'.
top-of-page during line-selection.
case sy-lsind.
when 1.
write : / ' sales details'.
when 2 .
write : / 'item details'.
endcase.

syd
Posts: 521
Joined: Fri Jul 04, 2003 1:17 am
Location: Sydney, Australia

Post by syd » Wed Jul 26, 2006 8:55 pm

Firstly read the Error Analysis section of the short dump before posting issues like these.
In a SELECT or FETCH command, the field string or internal table
specified in the INTO clause has 2 fields. It must have
at least as many fields as in the SELECT clause,
3 fields in this case.
which means, your itab has 2 fields but you are trying to populate 3 fields from the database into the same itab!

Code: Select all

DATA: BEGIN OF itab OCCURS 0,
kunnr   LIKE kna1-kunnr,
name1 LIKE kna1-name1,
END OF itab.
......
......
  SELECT kunnr name1 land1 FROM kna1 INTO TABLE itab WHERE kunnr IN cust.   "what were you thinking??!!
Correct data declaration should be:

Code: Select all

DATA: BEGIN OF itab OCCURS 0,
    kunnr   LIKE kna1-kunnr,
    name1 LIKE kna1-name1,
    land1   like kna1-land1,
END OF itab.
That at least should stop the short-dump....Also I noticed START-OF-SELECTION event occuring twice! Why on earth?
Cheers,
syd :)

Badrinath Thiriveedhi
Posts: 3
Joined: Thu Jun 29, 2006 7:36 am
Location: Secunderabad

Test this

Post by Badrinath Thiriveedhi » Thu Jul 27, 2006 3:21 am

try this code....

tables: kna1,vbak,vbap,mara.
select-options: cust for kna1-kunnr.
data: begin of itab occurs 0,
kunnr like kna1-kunnr,
name1 like kna1-name1,
land1 like kna1-land1,
end of itab.
data : begin of jtab occurs 0,
vbeln like vbak-vbeln,
netwr like vbak-netwr,
end of jtab.
Data: begin of ktab occurs 0,
posnr like vbap-posnr,
matnr like mara-matnr,
end of ktab.
data: fnam(10), fval(10).
start-of-selection.
select kunnr name1 land1 from kna1 into table itab where kunnr in cust.
loop at itab.
write :/ itab-kunnr hotspot,
itab-name1.
hide itab-kunnr.
endloop.
*start-of-selection.
at line-selection.
case sy-lsind.
when 1 .
select vbeln netwr from vbak into table jtab where kunnr = itab-kunnr.
loop at jtab.
write: / jtab-vbeln hotspot,
jtab-netwr.
hide jtab-vbeln.
endloop.
when 2.
select vbap~posnr mara~matnr into table ktab from vbap inner join mara
on vbap~matnr = mara~matnr where vbeln = jtab-vbeln.
loop at ktab.
write : / ktab-posnr,
ktab-matnr hotspot.
hide ktab-matnr.
endloop.
when 3.
get cursor field fnam value fval.
set parameter id 'mat' field fval.
call transaction 'mm02' and skip first screen .
endcase.
top-of-page.
write: / 'customer sudheer details'.
top-of-page during line-selection.
case sy-lsind.
when 1.
write : / ' sales details'.
when 2 .
write : / 'item details'.
endcase.

cheers
Badri 8)

abap_doctor
Posts: 6955
Joined: Thu Mar 25, 2004 11:29 am
Location: Airstrip One

Post by abap_doctor » Thu Jul 27, 2006 3:51 am

Could everyone please start using CODE BLOCKS for any code examples...

e.g. Hilight code then press button marked "Code"...

Thank you.

:twisted:
The Doc
Tuly Idiot Magna Grand Docot Image

wizbongre
Posts: 255
Joined: Thu Dec 19, 2002 8:19 am

Post by wizbongre » Thu Jul 27, 2006 7:17 am

This is my first visit to SAPFANS for longer than I care to remember...

It's exactly this sort of thread that stopped me looking in the first place.

What is it with the internet and forums that seems to have bred a culture of people just asking others to do their work for them?!

Anyway...

Post Reply