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

Problem with Select Statement

Former Member
0 Likes
730

I'm giving input through Flat file using WS_UPLOAD.storing it_txt_upload.(which contains all the personal numbers came from Flat file)

and trying to read the data from table PA0006 into it_p0006

using for all entries.

it is not taking some of the personal numbers.

i have checked in Debug mode it is storing to it_txt_upload(53 personal numbers)

after select query it needs to take the entries for all the 53 personal numbers.

but it not taking all.

for all the personal numbers records are there in database.

Please help me.

i'm providing the code what i have written. please check it.

  • uploading the data from excel to internal table

call function 'WS_UPLOAD'

exporting

filename = 'H:\EMP_NO.TXT' " Input file

filetype = 'ASC'

tables

data_tab = t_txt_upload "internal table

exceptions

conversion_error = 1

file_open_error = 2

file_read_error = 3

invalid_type = 4

no_batch = 5

unknown_error = 6

invalid_table_width = 7

gui_refuse_filetransfer = 8

customer_error = 9

others = 10.

if sy-subrc ne 0.

message e030.

endif.

if not t_txt_upload[] is initial.

  • Get the data from table PA0006.

select pernr

begda

endda

anssa

stras

locat

ort01

ort02

pstlz

land1

telnr

com01

num01

com02

num02

from pa0006

into table it_p0006

for all entries in t_txt_upload

where pernr eq t_txt_upload-pernr.

if sy-subrc ne 0.

message I030.

endif.

sort it_p0006 by pernr.

delete adjacent duplicates from it_p0006.

endif.

6 REPLIES 6
Read only

Former Member
0 Likes
699

hi,

I think those pernrs are missing in PA0006 that's why its not retrieving data belongs to that pernrs.

goto se11 and check the pernrs in PA0006 comparing it_txt_upload-pernr .

Read only

Former Member
0 Likes
699

Hi Vamsi,

Please check that the data that you are picking from the presentation server has the same length as that of that in the SAP system... also some of the personal number's should match in your case....

What all problem can be there in you case...

- length of the data (may be key field) would be diff in both db table and the flat file.

- there would be no primary key's matching from db table with the key you have taken in your internnal table from flat file...

Regards,

Jayant

Please award if helpful

Read only

Former Member
0 Likes
699

HI vamsi,

Is pernrr a primary key in the table pa0006?

If pernr the only primary key then all data will be fetched..

If pernr has some other fields ( i mean pernr + some other field as primary key) then it will not fetch the redundant pernr values from the database..

reward if useful

regards,

nazeer

Message was edited by:

nazeer shaik

Read only

Former Member
0 Likes
699

Hi Vamsi

Check that it_p0006 structure,whether you declared it has internal table or work area.

Try looping it_txt_upload and

select

endloop.

Thanks

Read only

Former Member
0 Likes
699

first suggestion for you....do not use ws_upload as it is obsolete now. Use gui_upload method of the cl_gui_frontend_services class. or alternatively gui_upload function module.

check if the employee number is being populated in the correct field of your t_txt_upload from the file. it should come in the pernr field. i hope the field length in the internal table is long enough to hold the employee numbers.

your select query is correct. no problems there.

if you are sorting the table by pernr then add the comparing addition in the delete adjacent duplicates.

sort it_p0006 by pernr.

delete adjacent duplicates from it_p0006 comparing pernr.

regards,

Priyank

Read only

RaymondGiuseppi
Active Contributor
0 Likes
699

Have you looked at the data loaded in debug mode (to bypass cnversion) are the Personnel number right justified, padded with zeroes, if its not the case, maybe you have to LOOP at your internal table to correct this.

LOOP AT t_txt_upload.
  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
      input         = t_txt_upload-pernr
    IMPORTING
      OUTPUT        = t_txt_upload-pernr.
  MODIFY t_txt_upload.
ENDLOOP.

Regards