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: 

Could you help me .. ? I'm distracted regarding field-symbols.

former_member187400
Active Contributor
0 Kudos

Hi all,

If i have the code like this,


 data: data_ref type ref to data.
  field-symbols: <ls_data> type any
                 .

  create data data_ref like line of xth_data.
  assign data_ref->* to <ls_data>.

Over there, i create <ls_data> where it refer to table xth_data (this table has type hashed table).

Do you know what should i write the command ? if i want to delete the record from the xth_data .. ??

e.g. if i want to delete data no. 2 within xth_data ...

Really need your guidance .

Regards,

Niel.

1 ACCEPTED SOLUTION

matt
Active Contributor
0 Kudos

>

> Hi all,

>

> If i have the code like this,

>

>


>  data: data_ref type ref to data.
>   field-symbols: <ls_data> type any
>                  .
> 
>   create data data_ref like line of xth_data.
>   assign data_ref->* to <ls_data>.
> 

>

> Over there, i create <ls_data> where it refer to table xth_data (this table has type hashed table).

>

> Do you know what should i write the command ? if i want to delete the record from the xth_data .. ??

> e.g. if i want to delete data no. 2 within xth_data ...

>

> Really need your guidance .

>

> Regards,

> Niel.

So, you're writing BPS exit function? xth_data is hashed table, so the concept of 2nd record isn't really valid.

Let's say you want to delete a record where the field s_chas-currency has the value 'EUR'


data: data_ref type ref to data.
field-symbols: <ls_data> type any,
              <curr>   type /bi0/oicurrency.                .
 
create data data_ref like line of xth_data.
assign data_ref->* to <ls_data>.

ASSIGN COMPONENT 'S_CHAS-CURRENCY' OF STRUCTURE <ls_data> TO <curr>.

LOOP AT xth_data INTO <ls_data>.
  IF <curr> EQ 'EUR'.
    DELETE <ls_data> FROM TABLE xth_data.
  ENDIF.
ENDLOOP.

matt

4 REPLIES 4

matt
Active Contributor
0 Kudos

>

> Hi all,

>

> If i have the code like this,

>

>


>  data: data_ref type ref to data.
>   field-symbols: <ls_data> type any
>                  .
> 
>   create data data_ref like line of xth_data.
>   assign data_ref->* to <ls_data>.
> 

>

> Over there, i create <ls_data> where it refer to table xth_data (this table has type hashed table).

>

> Do you know what should i write the command ? if i want to delete the record from the xth_data .. ??

> e.g. if i want to delete data no. 2 within xth_data ...

>

> Really need your guidance .

>

> Regards,

> Niel.

So, you're writing BPS exit function? xth_data is hashed table, so the concept of 2nd record isn't really valid.

Let's say you want to delete a record where the field s_chas-currency has the value 'EUR'


data: data_ref type ref to data.
field-symbols: <ls_data> type any,
              <curr>   type /bi0/oicurrency.                .
 
create data data_ref like line of xth_data.
assign data_ref->* to <ls_data>.

ASSIGN COMPONENT 'S_CHAS-CURRENCY' OF STRUCTURE <ls_data> TO <curr>.

LOOP AT xth_data INTO <ls_data>.
  IF <curr> EQ 'EUR'.
    DELETE <ls_data> FROM TABLE xth_data.
  ENDIF.
ENDLOOP.

matt

0 Kudos

Tks a lot matt for your response ..

Yes, i'm writing the code for BPS .. :).

I've written the code, but i got an error:

the error goes on:


 DELETE <ls_data> FROM TABLE xth_data. 

the error message:

<ls_data> is not internal table.

Could you help me again matt ??

Really need your help.

Regards,

Niel.

0 Kudos

Tks math ..

It's already done ..

It should be:

DELETE TABLE xth_data FROM <ls_data>.

A huge appreciation has sent already ..

Regards,

Niel.

matt
Active Contributor
0 Kudos

Would you believe it was a deliberate error, just to help you learn? ( I was coding from memory ).

cheers

matt