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: 

Code optimization - Urgent

Former Member
0 Kudos
115

Hi All,

I have called the function module - 'CS_BOM_EXPL_MAT_V2' with respective parameters. Following the function call, i have written these lines, to display each material & the corresponding field from MARC. There is no syntax error, but the execution of this query takes a very long time, i had to terminate the execution.

May i know what could be the reason for this?

Code

IF SY-SUBRC EQ 0.

LOOP AT IL_STBX INTO HL_STBX.

WL_MATNR = HL_STBX-IDNRK.

SELECT SINGLE WEBAZ FROM MARC INTO WL_WEBAZ

WHERE MATNR EQ HL_STBX-IDNRK.

ENDLOOP.

Note: I have declared the DATA as mentioned below.

DATA :

IL_STBX TYPE TABLE OF STPOX,

HL_STBX TYPE STPOX.

REFRESH :

IL_STBX[].

CLEAR

HL_STBX.

Await your inputs.

Vivek

1 ACCEPTED SOLUTION

former_member156446
Active Contributor
0 Kudos
85

why dont u select the relavent data from MARC into another table and read it in loop.

or say for all entires in

8 REPLIES 8

former_member156446
Active Contributor
0 Kudos
86

why dont u select the relavent data from MARC into another table and read it in loop.

or say for all entires in

0 Kudos
85

Hi,

I am not quite clear of your inputs, can you please write down the code, so i can try to understand the same.

Vivek

0 Kudos
85

select matnr webaz from marc

into table it_marc

for all entires in IL_STBX

where matnr = HL_STBX-IDNRK.

LOOP AT IL_STBX INTO HL_STBX.

WL_MATNR = HL_STBX-IDNRK.

read table it_marc where matnr

if sy-subrc eq 0.

ur moves <<

endif .

ENDLOOP.

award points if helpful

0 Kudos
85

Hi,

The system prompts

'The formal argument "MATNR" occurs twice.'

Am not able to figure out why

Vivek

0 Kudos
85

check the spellings and decelerations of tables and in select satament too....

0 Kudos
85

Hi,

I believe i have made a fundamental error & that is the reason the program is going on a infinite loop. I just checked with the debugger, the program enters the 'Record Processing' section, reads the function module explodes the BOM, reads info from MARC table, upto this point it is ok. But what is happening is, the execution of the program does not stop after reading the BOM once, it keeps re-reading the BOM & that is why it is on an infinite loop.

Can you let me know how i can limit the execution of this program to read the BOM only once.

Hope i was able to put across the problem. Await your inputs.

Vivek

0 Kudos
85

if ur output is a table use a read statement rather than loop... ( i am not sure what ur output is from the FM)

or you have couple of other methods using sy-tabix, index...

loop at itab

if sy-index / sy-tabix GE 2.

exit.

endif.

endloop.

0 Kudos
85

Hi

Can you help me with the READ & Write statement? As i am not sure how to use these statements.

The internal table is IL_STBX & i need to read IDNRK & OJTXP fields in this & for each IDNRK i want to read MARC-WEBAZ & MARC-PLIFZ parameters & so i am not sure how to do this.

A Sample output for your ref.

IDNRK | WEBAZ | PLIFZ

Mtl123 | 2 | 23

Mtl124 | 5 | 12

& so on

Edited by: Vivek on Dec 26, 2007 5:52 PM