Application Development 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: 

Select & Validate data

Former Member
0 Kudos

Greeting to All,

Need your help on my below requirements. Appreciate you can provide me the coding guide. Thanks in advance for your help.

My upload file will contain 3 column of data as example on below.

<u>Service entry</u>

1000002000

<u>Company Code</u>

AB01

<u>Release Code</u>

A1

1. I need to validate SE number with the company code provided in the upload file from ESSR-LBLNI (SE number from template), then get ESSR-EBELN (PO number) from ESSR-EBELN, goto EKKO-EBELN and get EKKO-BUKRS

compare EKKO-BUKRs with company code in upload file.

2. If the data in upload file is not found, provide error message.

4 REPLIES 4

Former Member
0 Kudos

hi,

1 step : create internal table with said 3 field.

2 step : PARAMETERS: p_rfname LIKE rlgrap-filename OBLIGATORY.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_rfname.

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

( call txt file thru this code)

3 step : START-OF-SELECTION.

CALL FUNCTION 'WS_UPLOAD' ( to upload data from text file to internal table)

4 step : loop on internal table to validate your data.

thanks

raj

Former Member
0 Kudos

Hi All,

Appreciate all can provide me the coding guide for perform my validation & checking based on my requirement stated.

Thanks.

0 Kudos

Check the below Program :

REPORT ztest_ytt.

TABLES : essr,

ekko.

  • Internal table for File

DATA : BEGIN OF i_text OCCURS 0,

text(255) TYPE c,

END OF i_text.

  • Assume that you have data in ITAB.

DATA : BEGIN OF itab OCCURS 0,

se(10) TYPE c, " Service entry

bukrs(4) TYPE c, " Company code

rc(2) TYPE c, " Reason code

END OF itab.

  • Error Log internal table

DATA : BEGIN OF i_error OCCURS 0,

se(10) TYPE c,

bukrs(4) TYPE c,

text(100) TYPE c,

END OF i_error.

DATA v_file TYPE string.

PARAMETERS : p_file LIKE rlgrap-filename OBLIGATORY.

  • possible entry list (F4 dropdown) for input file name

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

*-SELECT FILE FROM USERS LOCAL PC

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

  • DEF_FILENAME = ' '

def_path = 'C:\Temp\'

mask = ',.,..'

mode = 'O'

title = 'Select File '(007)

IMPORTING

filename = p_file

  • RC =

EXCEPTIONS

inv_winsys = 1

no_batch = 2

selection_cancel = 3

selection_error = 4

OTHERS = 5.

IF sy-subrc <> 0.

  • MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

  • WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

*

START-OF-SELECTION .

  • Get the data from file to Internal table

PERFORM get_data_file.

  • Validation file data

PERFORM validate_data.

&----


*& Form get_data_file

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_data_file .

v_file = p_file.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = p_file

filetype = 'ASC'

  • HAS_FIELD_SEPARATOR = ' '

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE =

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

data_tab = i_text

EXCEPTIONS

file_open_error = 1

file_read_error = 2

no_batch = 3

gui_refuse_filetransfer = 4

invalid_type = 5

no_authority = 6

unknown_error = 7

bad_data_format = 8

header_not_allowed = 9

separator_not_allowed = 10

header_too_long = 11

unknown_dp_error = 12

access_denied = 13

dp_out_of_memory = 14

disk_full = 15

dp_timeout = 16

OTHERS = 17

.

IF sy-subrc NE 0.

MESSAGE e000(z01) WITH 'No data found'.

ELSE.

LOOP AT i_text.

  • Assume that your file is comma delimted text file

SPLIT i_text-text AT ',' INTO itab-se

itab-bukrs

itab-rc.

APPEND itab.

CLEAR : i_text,

itab.

ENDLOOP.

ENDIF.

ENDFORM. " get_data_file

&----


*& Form validate_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM validate_data .

DATA : wa_essr LIKE essr .

DATA : wa_ekko LIKE ekko.

LOOP AT itab.

CLEAR : wa_essr,

wa_ekko.

  • Compare the data with ESSR Table

SELECT SINGLE * FROM essr INTO wa_essr

WHERE lblni = itab-se.

IF sy-subrc EQ 0.

SELECT SINGLE * FROM ekko INTO wa_ekko

WHERE ebeln = wa_essr-ebeln

AND bukrs = itab-bukrs.

IF sy-subrc NE 0.

  • My assumption is no error message ,if you want to then you can give

  • message e000(z01) with 'No valid data'.

i_error-se = itab-se.

i_error-bukrs = itab-bukrs.

i_error-text = 'No valid data at Purchase order'.

APPEND i_error.

ENDIF.

ELSE.

i_error-se = itab-se.

i_error-bukrs = itab-bukrs.

i_error-text = 'No valid data at Purchase order'.

APPEND i_error.

ENDIF.

ENDLOOP.

ENDFORM. " validate_data

I guess you should not give any error message,if you give give error message ,then how about other records in file.

Simply keep all error records in one internal table,then display error log .

Thanks

Seshu

Former Member
0 Kudos

Thanks All.