Skip to Content
0
Former Member
Mar 03, 2009 at 01:07 PM

error with sorted internal table with unique key in select statement?

27 Views

Hi,

I got a Run-Time error when i used sorted internal table with unique key as below coding

TYPES : BEGIN OF ty_download,

ebeln TYPE ekko-ebeln,

bsart TYPE ekko-bsart,

ekorg TYPE ekko-ekorg,

bukrs TYPE ekko-bukrs,

lifnr TYPE lfa1-lifnr,

ekgrp TYPE ekko-ekgrp,

matnr TYPE mara-matnr,

menge TYPE ekpo-menge,

eindt TYPE eket-eindt,

netpr TYPE ekpo-netpr,

werks TYPE ekpo-werks,

lgort type ekpo-lgort,

mwskz type ekpo-mwskz,

submi type ekko-submi,

END OF ty_download.

TYPES : BEGIN OF ty_ekko,

ebeln TYPE ekko-ebeln,

bukrs TYPE ekko-bukrs,

bsart TYPE ekko-bsart,

lifnr TYPE ekko-lifnr,

ekorg TYPE ekko-ekorg,

ekgrp TYPE ekko-ekgrp,

submi type ekko-submi,

END OF ty_ekko.

TYPES : BEGIN OF ty_ekpo,

ebeln TYPE ekpo-ebeln,

ebelp TYPE ekpo-ebelp,

matnr TYPE ekpo-matnr,

werks TYPE ekpo-werks,

lgort TYPE ekpo-lgort,

matkl TYPE ekpo-matkl,

menge TYPE ekpo-menge,

netpr TYPE ekpo-netpr,

mwskz type ekpo-mwskz,

END OF ty_ekpo.

TYPES : BEGIN OF ty_eket,

ebeln TYPE eket-ebeln,

ebelp TYPE eket-ebelp,

eindt TYPE eket-eindt,

END OF ty_eket.

DATA : it_ekko TYPE sorted TABLE OF ty_ekko with unique key ebeln,

it_ekpo TYPE sorted TABLE OF ty_ekpo with unique key ebeln ebelp,

it_eket TYPE sorted TABLE OF ty_eket with unique key ebeln ebelp,

it_download TYPE TABLE OF ty_download,

it_header TYPE TABLE OF ty_header.

DATA : gv_date TYPE ekko-aedat.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE tit_name.

SELECT-OPTIONS : s_date FOR gv_date.

SELECTION-SCREEN END OF BLOCK b1.

INITIALIZATION.

tit_name = text-001.

AT SELECTION-SCREEN.

PERFORM : validate_date.

START-OF-SELECTION.

PERFORM :

read_ekko_data,

read_ekpo_data,

read_eket_data,

prepare_po_data,

prepare_header,

download_data.

&----


*& Form validate_date

&----


  • text

----


FORM validate_date .

DATA : l_date LIKE gv_date.

SELECT SINGLE bedat

FROM ekko

INTO l_date

WHERE aedat IN s_date.

IF sy-subrc <> 0.

MESSAGE e000 WITH 'Date not Found'.

ENDIF.

ENDFORM. " validate_date

&----


*& Form read_ekko_data

&----


  • text

----


FORM read_ekko_data .

IF it_ekko[] IS INITIAL.

SELECT ebeln

bukrs

bsart

lifnr

ekorg

ekgrp

submi

FROM ekko

INTO TABLE it_ekko

WHERE aedat IN s_date.

IF sy-subrc <> 0.

MESSAGE e000 WITH 'No PO Created in Specified Date'.

ENDIF.

ENDIF.

ENDFORM. " read_ekko_data

&----


*& Form read_ekpo_data

&----


  • text

----


FORM read_ekpo_data .

IF it_ekko[] IS NOT INITIAL.

SELECT ebeln

ebelp

matnr

werks

lgort

matkl

menge

netpr

mwskz

FROM ekpo

INTO TABLE it_ekpo

FOR ALL ENTRIES IN it_ekko

WHERE ebeln = it_ekko-ebeln.

ENDIF.

ENDFORM. " read_ekpo_data

&----


*& Form read_eket_data

&----


  • text

----


FORM read_eket_data .

IF it_ekpo[] IS NOT INITIAL.

SELECT ebeln

ebelp

eindt

FROM eket

INTO TABLE it_eket

FOR ALL ENTRIES IN it_ekpo

WHERE ebeln = it_ekpo-ebeln

AND ebelp = it_ekpo-ebelp.

ENDIF.

ENDFORM. " read_eket_data

&----


*& Form prepare_po_data

&----


  • text

----


FORM prepare_po_data .

field-symbols : <fs_ekko> LIKE LINE OF it_ekko,

<fs_ekpo> LIKE LINE OF it_ekpo,

<fs_eket> LIKE LINE OF it_eket.

DATA : ls_download LIKE LINE OF it_download.

LOOP AT it_ekpo assigning <fs_ekpo>.

READ TABLE it_ekko assigning <fs_ekko> WITH table KEY ebeln = <fs_ekpo>-ebeln.

IF sy-subrc = 0.

CLEAR ls_download.

ls_download-ebeln = <fs_ekko>-ebeln.

ls_download-bsart = <fs_ekko>-bsart.

ls_download-ekorg = <fs_ekko>-ekorg.

ls_download-bukrs = <fs_ekko>-bukrs.

ls_download-lifnr = <fs_ekko>-lifnr.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'

EXPORTING

input = ls_download-lifnr

IMPORTING

OUTPUT = ls_download-lifnr.

ls_download-matnr = <fs_ekpo>-matnr.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'

EXPORTING

input = ls_download-matnr

IMPORTING

OUTPUT = ls_download-matnr.

ls_download-werks = <fs_ekpo>-werks.

ls_download-menge = <fs_ekpo>-menge.

ls_download-netpr = <fs_ekpo>-netpr.

ls_download-ekgrp = <fs_ekko>-ekgrp.

ls_download-submi = <fs_ekko>-submi.

ls_download-mwskz = <fs_ekpo>-mwskz.

READ TABLE it_eket assigning <fs_eket> WITH table KEY ebeln = <fs_ekpo>-ebeln

ebelp = <fs_ekpo>-ebelp.

IF sy-subrc = 0.

ls_download-eindt = <fs_eket>-eindt.

ENDIF.

COLLECT ls_download INTO it_download.

CONTINUE.

ENDIF.

ENDLOOP.

ENDFORM. " prepare_po_data

can anyone suggest me how to solve this