cancel
Showing results for 
Search instead for 
Did you mean: 

How to read an internal table filled in a start routine?

Former Member
0 Kudos

Hello,

I have filled an internal table in a start routine of a update rule and, I need know to read that table and fill the field value (in the update rule).

How can I do this?

Perhaps, should I have to use the DATA_PACKAGE STRUCTURE?

Thanks in advance.

Regards.

Accepted Solutions (0)

Answers (9)

Answers (9)

shahidimam_shaik
Active Participant
0 Kudos

Hi David,

In the start routine of the transformation, you have to use the structures and internalt tables declared by sap, in the transformation program.

If you want to write Start routine in the update rules of 3x flow, please follow the below link.

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d0cc9103-9d7f-2e10-a796-a17ef43b4...

For Start routine in 7.0:

Structure present: _ty_s_sc_1

Table present     : _ty_t_sc_1

Internal table      : Source_package

Field symbol      :  <source_fields>

Now, you need to share your code for the clear understanding. however, I am giving you a pseudo code for reading the table and modifying thee data in the start routine.

data lt_source_pak type table of _ty_s_sc_1.

data ls_source_pak type _ty_s_sc_1.

.......

.......

Loop at source_package assigning <source_fields>.

read table lt_source_pak into ls_source_pak with key customer = ls_source_pak-customer.

If sy-subrc = 0.

ls_source_pak-customer = <source_fields>-customer.

endif.

endloop.

Hope this code gives you idea of start routine in 7.0. The document which I have shared url will give you thorough scenario of writing start routine in update rules. If useful please assign points..

Best regards,

Shahid.

former_member205094
Participant
0 Kudos

This message was moderated.

Former Member
0 Kudos

Hi:

Here is a simple one: check if DSO material number is in 0material masterdata.  If so the net price is shown, if not the net price is forced to 0.

Start routine

*$*$ begin of global - insert your declaration only below this line  *-*
Types: Begin of ty_material,
   MATERIAL type /BI0/PMATERIAL-MATERIAL,
   VENDOR type /BI0/PMATERIAL-VENDOR,
   VOLUME type /BI0/PMATERIAL-VOLUME,
   end of ty_material.


DATA: tb_material type table of ty_material.


*$*$ begin of routine - insert your code only below this line        *-*
... "insert your code here
*--  fill table "MONITOR" with values of structure "MONITOR_REC"
*-   to make monitor entries
... "to cancel the update process
*    raise exception type CX_RSROUT_ABORT.


Clear tb_material.

select MATERIAL VENDOR VOLUME
into table tb_material
from /BI0/PMATERIAL
where VOLUME is null.

Individual routine (on net price) -> feed net price field with net price and material info in your transformation.

DATA: ts_material like line of tb_material.

Read table tb_material into ts_material
with key MATERIAL = source_fields-material.


If sy-subrc = 0.

      RESULT = source_fields-net_price.

  else.
    RESULT = 0.

    endif.

Hope this helps!



RafkeMagic
Active Contributor
0 Kudos

are you really using "update rules" (and not "transformations")?

in that case, only the answer of Anshu Lilhoriwill be helpful, the others refer to 7.x logic

(also for the other posters: result_package is used in an END routine, not in a FIELD routine - and David was definitely talking about a field routine)

Former Member
0 Kudos

Hi

You are trying to do look up on some other table then you can use the below code as same.

DATA: IT_RESULT_PACKAGE TYPE STANDARD TABLE OF _TY_S_TG_1,

      WA_RESULT_PACKAGE TYPE _TY_S_TG_1.

**Defining the structure******

TYPES: BEGIN OF X,

     

END OF X.

**********

**Defining internal table and Work area************** 

DATA: LT_X  TYPE STANDARD TABLE OF X,

      LS_X  TYPE X.

***********************************************************

CLEAR : WA_RESULT_PACKAGE,LT_X,LS_X.

REFRESH : IT_RESULT_PACKAGE.

**Select the data and put into inernal table ***************

SELECT  A B FROM C INTO TABLE LT_X

        FOR ALL ENTRIES  IN RESULT_PACKAGE WHERE A =

        RESULT_PACKAGE-A

***********************************************************************

LOOP AT RESULT_PACKAGE INTO WA_RESULT_PACKAGE.

   READ TABLE LT_X INTO LS_X

   WITH KEY A= WA_RESULT_PACKAGE-A BINARY SEARCH.

   IF SY-SUBRC = 0.

      WA_RESULT_PACKAGE-E = LS_X-K.

   ENDIF.

   APPEND WA_RESULT_PACKAGE TO IT_RESULT_PACKAGE.

ENDLOOP.

REFRESH RESULT_PACKAGE.

RESULT_PACKAGE = IT_RESULT_PACKAGE.

Thanks
Srini

anshu_lilhori
Active Contributor
0 Kudos

Hi David,

Please share the piece of code you have written..I have already given guidelines in your earlier thread regarding internal table declaration.

Read table it_xy into wa_xy with key

employee = comm-strucutre-employee.

If sy-subrc = 0.

then pass the value into the required field which needs to be updated.

Hope this helps.

Regards,

AL

former_member224107
Participant
0 Kudos

If used in a transformation rule :

READ TABLE internal_table WITH KEY key1 = source_fields-field1 key2 = source_fields-field2 INTO work_area.

RESULT = work_area-resultfield

RamanKorrapati
Active Contributor
0 Kudos

Hi,

For start routine you need to use SOURCE_PACKAGE.

For end routine we use RESULT_PACKAGE. You can search on Google you will get useful  docs.

Thanks

former_member182470
Active Contributor
0 Kudos

For updating, you should use RESULT_PACKAGE.