cancel
Showing results for 
Search instead for 
Did you mean: 

select statement

Former Member
0 Kudos

Hi to all,

Can anyone correct the select statement ....it is activating but in Debugging there is no entries in ITAB

...

*&----


*& Report ZGTB_REPORT *

*& *

&----


*& *

*& *

&----


REPORT ZGTB_REPORT .

TABLES: MARD, /UPM/GTB10.

DATA: BEGIN OF ITAB OCCURS 0,

EXTMATLGRP TYPE /UPM/GTB10-EXTMATLGRP,

LAGERORT TYPE /UPM/GTB10-LAGERORT,

MATERIAL TYPE /UPM/GTB10-MATERIAL,

LAGERPLATZ TYPE /UPM/GTB10-LAGERPLATZ,

BESCHREIBUNG TYPE /UPM/GTB10-BESCHREIBUNG,

VIN TYPE /UPM/GTB10-VIN,

HERSTELLER TYPE /UPM/GTB10-HERSTELLER,

VCOLOR TYPE /UPM/GTB10-VCOLOR,

KILOMETER TYPE /UPM/GTB10-KILOMETER,

ENOTIZ TYPE /UPM/GTB10-ENOTIZ,

NETPR TYPE /UPM/GTB11-NETPR,

BEDAT TYPE EKKO-BEDAT,

LABST TYPE /UPM/GTB10-QUANTITY,

MATNR LIKE /UPM/GTB10-MATERIAL,

END OF ITAB.

DATA: BEGIN OF ITAB1 OCCURS 0,

MATNR TYPE MARD-MATNR,

LABST TYPE MARD-LABST,

END OF ITAB1.

*DATA: LABST LIKE MARD-LABST,

  • MATNR LIKE MARD-MATNR.

*DATA: P_FNAME TYPE RLGRAP-FILENAME.

*******************************SELECT OPTION*************************

PARAMETERS: P_FNAME LIKE rlgrap-filename

DEFAULT 'c:\temp' OBLIGATORY. " File Nameselect

**************************SELECT*************************************

START-OF-SELECTION.

SELECT MATNR LABST from MARD into table ITAB1 WHERE LABST GT 0.

LOOP AT ITAB1.

CLEAR /UPM/GTB10.

SELECT * FROM /UPM/GTB10 INTO CORRESPONDING FIELDS OF TABLE ITAB WHERE

MATERIAL = ITAB1-MATNR.

append itab.

ENDLOOP.

***********************OPEN DATASET***********************************

OPEN DATASET P_FNAME IN TEXT MODE ENCODING DEFAULT FOR OUTPUT.

IF SY-SUBRC = 0.

LOOP AT ITAB.

TRANSFER ITAB TO P_FNAME.

ENDLOOP.

ENDIF.

CLOSE DATASET P_FNAME.

IF SY-SUBRC = 0.

ENDIF.

***********************************CALL FUNCTION GUI DOWNLOAD*********

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

FILENAME = 'P_FNAME'

FILETYPE = 'ASC'

  • APPEND = ' '

  • WRITE_FIELD_SEPARATOR = ' '

  • HEADER = '00'

  • TRUNC_TRAILING_BLANKS = ' '

  • WRITE_LF = 'X'

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • WRITE_BOM = ' '

  • TRUNC_TRAILING_BLANKS_EOL = 'X'

  • IMPORTING

  • FILELENGTH =

TABLES

DATA_TAB = ITAB

  • FIELDNAMES =

EXCEPTIONS

FILE_WRITE_ERROR = 1

NO_BATCH = 2

  • GUI_REFUSE_FILETRANSFER = 3

  • INVALID_TYPE = 4

  • NO_AUTHORITY = 5

  • UNKNOWN_ERROR = 6

  • HEADER_NOT_ALLOWED = 7

  • OTHERS = 22

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Thanks in advance,

raju.

Accepted Solutions (1)

Accepted Solutions (1)

abdul_hakim
Active Contributor
0 Kudos

Hi Use the below code,

IF NOT ITAB1[] IS INITIAL.

SELECT * FROM /UPM/GTB10

INTO CORRESPONDING FIELDS OF TABLE ITAB

for all entries in itab1

WHERE MATERIAL = ITAB1-MATNR.

ENDIF.

This will improve ur performance...

REgards,

Abdul

Answers (4)

Answers (4)

Former Member
0 Kudos

START-OF-SELECTION.

SELECT MATNR LABST from MARD into table ITAB1 WHERE LABST GT 0.

<b>if sy-subrc = 0.</b>

SELECT * FROM /UPM/GTB10 INTO CORRESPONDING FIELDS OF TABLE ITAB

<b>for all enteries in iTAB1</b>

WHERE

MATERIAL = ITAB1-MATNR.

<b>endif.</b>

Thanks

Kam

Former Member
0 Kudos

Hi Raju,

What Srilatha said is perfect.

It also saves you from not doing the select within the loop.

Rgds,

Prash.

Former Member
0 Kudos

Hi Ragu,

After selecting data from MARD and moving into

Itab1.

Do the below:

if not itab1[] is initial.

SELECT * FROM /UPM/GTB10

INTO CORRESPONDING FIELDS OF TABLE ITAB

for all entries in itab1

WHERE MATERIAL = ITAB1-MATNR.

endif.

Hope this will work you.

Thanks & Regards,

Siri

Former Member
0 Kudos

HI TO ALL,

The length of the material in

MATERIAL-/UPM/GTB10 is 40

MATNR-MARD is 18...

in this what i have to do...

raju..

abdul_hakim
Active Contributor
0 Kudos

Hi,

No problem change the length similar to MATERIAL-/UPM/GTB10

REgards,

Abdul

Former Member
0 Kudos

Change your first SELECT to the following.

SELECT MATNR LABST from MARD into CORRESPODING FIELDS of table ITAB1 WHERE LABST GT 0.

Regards,

Ravi

Note : Please reward the helpful answers.