Skip to Content
author's profile photo Former Member
Former Member

Enhancing the fields from one DB table to the Generic datasource

Hi Experts,

I have created a generic datasource 'ZKRB_WIP'. I need fields like BRGEW(gross weight in KG), VERPR(moving average price), etc.. to calculate WIP weight in KG, WIP value directly. I have created other Generic datasources to get other needed fields for the report.

This datasource contains a view ZMARM, which is built from MARM table fields BRGEW, GEWEI, MATNR.

Now, I have enhanced the datasource with database table QBEW fields, the fields are given below.

VERPR(moving average price), STPRS(Standard price), PEINH(unit price).

I appended these fields to the extract structure of the datasource 'ZKRB_WIP'.

The extract structure name of the datasource is ZOXDEV0125.

The append structure name of the extract structure is ZZZOXDEV0125.

The code i have written to get the fields of the database table QBEW is given below:

I have tried to give selections, and then I just commented the code for selections, please ignore it.

here I have given the code which I wrote for enhacement, which is not working. Any inputs, sample codes,

would be appreciable. One doubt I have in this code is I have given append structure as include. Generally,

we just make a work area(header line) of the extract structure, and do a loop for example.

when 'i_datasource'.

data wa type extract struct.

loop at c_t_data into wa.

select single field1, field2.. from Table1 into ( wa-field1, wa-field2 ).

modify c_t_data from wa.

end loop.

any modifications or ideas for given code below is appreciable. Please ignore the commented code.

WHEN 'ZKRB_WIP'.

TYPES: BEGIN OF TY_QBEW,
MATNR TYPE MATNR,
INCLUDE TYPE ZZZOXDEV0125,
END OF TY_QBEW.

DATA: LS_ZOXDEV0125 TYPE ZOXDEV0125,
WA_QBEW TYPE TY_QBEW,
LT_QBEW TYPE TABLE OF TY_QBEW.
* LR_MATNR TYPE RANGE OF QBEW-MATNR WITH HEADER LINE,
* LR_ZKDAT TYPE RANGE OF QBEW-ZKDAT WITH HEADER LINE.

* TYPES: TY_R_MATNR TYPE RANGE OF QBEW-MATNR,
* TY_R_ZKDAT TYPE RANGE OF QBEW-ZKDAT.
* CLEAR L_S_SELECT.
* LOOP AT I_T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'MATNR'.
* MOVE-CORRESPONDING L_S_SELECT TO LR_MATNR.
* APPEND LR_MATNR.
* ENDLOOP.

* CLEAR L_S_SELECT.
* LOOP AT I_T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'ZZZKDAT'.
* MOVE-CORRESPONDING L_S_SELECT TO LR_ZKDAT.
* APPEND LR_ZKDAT.
* ENDLOOP.

SELECT MATNR VERPR STPRS PEINH ZKDAT
FROM QBEW
INTO TABLE LT_QBEW.

CLEAR: L_TABIX.
LOOP AT C_T_DATA INTO LS_ZOXDEV0125.
L_TABIX = SY-TABIX.
READ TABLE LT_QBEW INTO WA_QBEW WITH KEY MATNR = LS_ZOXDEV0125-MATNR.
IF SY-SUBRC = 0.
MOVE-CORRESPONDING WA_QBEW TO LS_ZOXDEV0125.
MODIFY C_T_DATA FROM LS_ZOXDEV0125 INDEX L_TABIX.
CLEAR LS_ZOXDEV0125.
ENDIF.
ENDLOOP.
ENDCASE.

correct answers would be apreciated, Points will be rewarded.

Message was edited by: Shahid Imam Shaik

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Jun 04, 2012 at 12:23 PM

    Hi

    In select statement you missed out Where part please include where part from extract stricture fields and table fileds.

    Jagadeesh

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Jagadeesh,

      Thank you for the input, but when i give WHERE MATNR = LT_QBEW-MATNR, it gives me sytax error, saying LT_QBEW is a table without header line, therefore has no component with the name MATNR. Can you please give me the part of code which could work here?

      Best regards,

      Shahid.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.