cancel
Showing results for 
Search instead for 
Did you mean: 

Reading table using ABAP

former_member199653
Participant
0 Kudos

dear all,

below is a sql stmt which does a query to an ODS in BW. What i'm trying to archieve is to assign value bbp_po_id to a key field within an ODS. I dont know ABAP and how to return a single value back to BW. Can someone please show guide me?

SELECT bbp_po_id bbp_poitem

FROM /BIC/AZCF_O100

INTO TABLE lt_cfsrm_po

WHERE bbp_po_id = COMM_STRUCTURE-bbp_po_id

AND bbp_poitem = COMM_STRUCTURE-bbp_poitem

AND prod_type = '02'.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

hI,

Use the below coe in the start routinf of Update rules.

TYPES: BEGIN OF ITAB_STRUCTURE,

bbp_po_id like /BIC/AZCF_O100-bbp_po_id,

bbp_poitem like /BIC/AZCF_O100-bbp_poitem,

bbp_coitem like /BIC/AZCF_O100-bbp_coitem ,

TYPES END OF ITAB_STRUCTURE.

DATA:

lt_cfsrm_po TYPE SORTED TABLE OF ITAB_STRUCTURE

WITH HEADER LINE

WITH NON-UNIQUE KEY bbp_po_id bbp_poitem INITIAL SIZE 0.

SELECT bbp_po_id bbp_poitem bbp_coitem FROM /BIC/AZCF_O100 INTO

CORRESPONDING FIELDS OF TABLE lt_cfsrm_po

FOR ALL ENTRIES IN DATA_PACKAGE

WHERE bbp_po_id = DATA_PACKAGE-bbp_po_id

AND bbp_poitem = DATA_PACKAGE-bbp_poitem

AND prod_type = '02'.

LOOP AT DATA_PACKAGE.

READ TABLE lt_cfsrm_po WITH KEY bbp_po_id = DATA_PACKAGE-bbp_po_id

bbp_poitem = DATA_PACKAGE-bbp_poitem.

IF SY-SUBRC EQ 0.

DATA_PACKAGE-bbp_coitem = lt_cfsrm_po-bbp_coitem.

mODIFY DATA_PACKAGE.

ENDIF.

endloop.

With rgds,

Anil Kumar Sharma .P

edwin_harpino
Active Contributor
0 Kudos

hi Simon,

a bit confuse .... the code will return the same bbp_po_id and bbp_poitem,

since the condition/WHERE clause use same field.

to return single value you can use code like

SELECT single *

FROM /BIC/AZCF_O100

INTO TABLE lt_cfsrm_po

WHERE .....

if sy-subrc = 0.

result = lt_cfsrm_po-bbp_po_id.

endif.

  • result = ods key field to be filled

  • if your ods has large volume data, you may consider to put the select in global area, and retrieve later in each routine, and if performance still suffer, consider indexing

in global area

SELECT *

FROM /BIC/AZCF_O100

INTO TABLE lt_cfsrm_po

WHERE .....

in routine

read table lt_cfsrm_po with key fieldname = comm_structure-fieldname binary search.

if sy-subrc = 0.

result = lt_cfsrm_po-bbp_po_id.

endif.

you will need at least a field that can match to the ods and return the other field(s).

hope this helps.

former_member199653
Participant
0 Kudos

Edwin,

I'm glad you replied. Well, i actually want bbp_coitem but thanks for the quick response. I will have to try out the code below later. Thanks again for the insight and i've award point.