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

Syntax for READ (specific case)

Former Member
0 Likes
741

Dear All,

I have an internal table - itab, which has 2 fields. I would like to know how i can i read the values stored at index 1 into 2 different variables.

eg: internal table

matnr | date

ABC | 2.1.2000

XYZ | 2.1.2004

CVF | 2.1.2007

i want to read only the values stored at index 1 of matnr into a variable var_matnr & date into var_date

i.e. var_matnr = ABC & var_date = 2.1.2000

If it is not possible to manage this with a READ, any alternative way?

Await inputs.

Vivek

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
720

Hi Vivek,

You can read the values to a work area and then assign it like...

declare a workarea type the same as internal table...

read table int_table into workarea index 1.

var_matnr = workarea-matnr . "ABC

var_date = workarea-date . "2.1.2000

clear workarea.

This is the easiest way....

Regards

Byju

4 REPLIES 4
Read only

Former Member
0 Likes
721

Hi Vivek,

You can read the values to a work area and then assign it like...

declare a workarea type the same as internal table...

read table int_table into workarea index 1.

var_matnr = workarea-matnr . "ABC

var_date = workarea-date . "2.1.2000

clear workarea.

This is the easiest way....

Regards

Byju

Read only

Former Member
0 Likes
720

Hi,

yes yaar u can do.

u can use

READ TABLE <table name> INTO <workarea> WITH KEY MATNR = ............ DATE = ..........

or

u can use this if the record is the first record in the internal table.

READ TABLE <table name> INTO <workarea> INDEX 1.

<REMOVED BY MODERATOR>

RAAM

Edited by: Alvaro Tejada Galindo on Apr 14, 2008 6:18 PM

Read only

Former Member
0 Likes
720

Hi Vivek,

Do this way...



data : wa like itab, " wa shd hv similar structure as itab Or if hv itab with header line then no need of work area..

var1 type mara-matnr,
var2 type sy-datum.

read table itab into wa index 1.
var1 = wa-matnr .
var2 = wa-date . 
clear wa.

Hope it will solve your problem

Thanks & Regards

ilesh 24x7

Read only

Former Member
0 Likes
720

Dear All,

Thank you very much for your quick help & guidance.

Keep the good work going.

Regards,

Vivek