Application Development and Automation 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: 
Read only

Dual Nature for Abap code.

Former Member
0 Likes
3,419

Hi,

Requirment is

For a Material,

Orders required quantity

components for that material

their requirment.

my program takes material and orders from RESB table.

to get components i am looping through header table using Function module -'CS_BOM_EXPL_MAT_V2'.

If i do the debugginf i am able to see that data is going properly to internal table. but when i execute, Components data is missing.

Any body can help me in this?

What might be the cause?

Regards,

Lijo Joseph

.

1 ACCEPTED SOLUTION
Read only

athavanraja
Active Contributor
0 Likes
3,360

It will be really difficult to address your issue with the info. you have given. Can you post the code here , that will help us to analyze it better.

Regards

Raja

Hi,

Requirment is

For a Material,

Orders required quantity

components for that material

their requirment.

my program takes material and orders from RESB table.

to get components i am looping through header table using Function module -'CS_BOM_EXPL_MAT_V2'.

If i do the debugginf i am able to see that data is going properly to internal table. but when i execute, Components data is missing.

Any body can help me in this?

What might be the cause?

Regards,

Lijo Joseph

.

33 REPLIES 33
Read only

athavanraja
Active Contributor
0 Likes
3,361

It will be really difficult to address your issue with the info. you have given. Can you post the code here , that will help us to analyze it better.

Regards

Raja

Read only

0 Likes
3,360

SELECT aufnr matnr werks bdmng meins bdter INTO CORRESPONDING FIELDS OF TABLE it_resb FROM resb WHERE aufnr IN s_aufnr AND matnr IN s_matnr.

IF sy-subrc <> 0.

MESSAGE 'No Values Found' TYPE 'I'.

LEAVE LIST-PROCESSING.

ENDIF.

**Checking Status of order.

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

  • LOOP AT it_afko.

  • CALL FUNCTION 'ZPP_VALID_REL_ORDER'

  • EXPORTING

  • aufnr = it_afko-lead_aufnr

  • IMPORTING

  • valid = it_afko-stat.

  • MODIFY it_afko TRANSPORTING stat.

  • ENDLOOP.

  • DELETE it_afko WHERE stat = 'N'.

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

DELETE it_resb WHERE aufnr = space.

SORT it_resb BY matnr.

LOOP AT it_resb.

ON CHANGE OF it_resb-matnr.

FORMAT COLOR COL_HEADING ON.

WRITE:/ sy-vline,it_resb-matnr,sy-uline.

FORMAT COLOR OFF.

ENDON.

WRITE:/ sy-vline,it_resb-aufnr,it_resb-bdmng,it_resb-meins.

AT END OF matnr.

READ TABLE it_resb INDEX sy-tabix.

SUM.

l_bdmng = it_resb-bdmng.

PERFORM bom_explode.

LOOP AT stb.

WRITE:/ sy-vline,stb-idnrk,stb-mnglg.

ENDLOOP.

WRITE: sy-uline.

ENDAT.

ENDLOOP.

TOP-OF-PAGE.

CALL FUNCTION 'ZCA_REPORT_HEADER'

EXPORTING

hdval = 'Cutting List For Stores'

rpsize = 130

plant = 'BLR'.

&----


*& Form bom_explode

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM bom_explode .

CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'

EXPORTING

aufsw = ' '

aumng = 0

capid = 'PP01'

datuv = sy-datum

ehndl = '1'

emeng = it_resb-bdmng

mktls = 'X'

mehrs = 'X'

mtnrv = it_resb-matnr

stpst = 0

svwvo = 'X'

werks = it_resb-werks

vrsvo = 'X'

IMPORTING

topmat = topmat

dstst = dstst

TABLES

stb = stb

matcat = matcat

EXCEPTIONS

alt_not_found = 1

call_invalid = 2

material_not_found = 3

missing_authorization = 4

no_bom_found = 5

no_plant_data = 6

no_suitable_bom_found = 7

conversion_error = 8

OTHERS = 9.

IF sy-subrc <> 0.

  • MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

  • WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ELSE.

WRITE:/ sy-uline.

ENDIF.

ENDFORM. " bom_explode

Read only

0 Likes
3,360

The subject line of this message has been very interesting.

Some questions that come to my mind are :

a) Do you see the output perfectly in debugging mode ?

b) Is the subroutine <i>bom_explode</i> working as you have intended it to ?

Something to try :

a) In debugging mode, try pressing F6 when it comes to the <b>PERFORM bom_explode</b>, line, and check whether the internal table still has proper values ?

b) Try the same with F5 and check again if it has proper values ?

c) If it does not, check whether the values of it_resb internal table are proper while you pass it to the function module.

d) Instead of using '<b>ON CHANGE OF</b>', try <b>'AT NEW MATNR'</b>. It is a little dangerous to use 'ON CHANGE OF' in LOOP.

As far as I have seen, there might be some oversight/trivial issue which needs to be solved with patience.

Hope this helps.

Regards,

Subramanian V.

Read only

0 Likes
3,360

Hi,

Its clear now.

You are looping at it_resb and within that loop <b>at end of matnr</b> you have <b>PERFORM bom_explode</b>.

In that perform you are calling FM 'CS_BOM_EXPL_MAT_V2' and passing it_resb-bdmng ,it_resb-matnr and it_resb-werks .

In this case since the perfrom is within at end of and end at the vales of it_resb-bdmng & it_resb-werks will be ******* , only the value of matnr will be there .

I am surprised that it worked in debuggin.

try moving the it_resb to a work area before using at end of stt. and use that to pass it to the function.

Hope i am clear.

Regards

Raja

Read only

0 Likes
3,360

Hello Raja,

Before the subroutine call, the read statement


READ TABLE it_resb INDEX sy-tabix.

would populate the header. Correct me if I'm wrong.

Joseph :

Sorry if this sounds a little silly, but did you, by accident declare another STB internal table within the subroutine? Because, in that case, the declaration you have made globally will always be empty. And in the debugging mode you will still be able to see the entries in the internal table (the one that's declared locally)

Please do get back on this one.

Regards,

Anand Mandalika.

Read only

0 Likes
3,360

1)I am getting Result perfectly in Debugging mode when i go through it by pressing f6.

2)Subroutine is working accrding to the expectation when i do debugging.

When debugging comes to Internal table data is populated in internal table.

Let me clear one thing.. Why you have mention use of on change is danger? in what aspect?

Regards,

Lijo Joseph

Read only

0 Likes
3,360

Hello Poornanand Mandalika ,

AS you said my read statement populate the header.

I have not declared two internal tables.

i am getting output properly while i do debugging by pressing f6 and excecute it.

If required i will write whole code in the forum.

Regards,

Lijo Joseph

Read only

0 Likes
3,360

Hi Anand,

Sorry i missed the stt. you are correct, that would populate the header.

Joseph :

When you come out of the perform, and try to loop at stb, are the values available in stb. If not then i would assume that stb is not declared globally.

Regards

Raja

Read only

0 Likes
3,360

Hello Durai raj,

I am getting data in STB after performing BOM explode.

Even i get desired output if i go through debugging.

Only if i execute directly, i am loosing some data which comes from BOM Function module.

Will it be because of lack of authorizations?

Regards,

Lijo Joseph

Read only

0 Likes
3,360

Hi,

I still feel the problem should not lie with/without debugging.

The below note has been fetched from SAP Help, why ON CHANGE OF should not be used with LOOP.


Note

There are special control structures for processing control breaks in 

LOOPs on internal tables or extract datasets ( 
AT ).

ON CHANGE OF is unsuitable for recognizing control levels
in loops of this type because it always creates a global 
auxiliary field which is used to check for changes. This 
global auxiliary field is only changed in the relevant ON 
CHANGE OF statement. It is not reset when the processing
enters loops or subroutines, so unwanted effects can 
occur if the loop or subroutine is executed again. Also, 
since it is set to its initial value when created (like 
any other field), any ON CHANGE OF processing will be 
executed after the first test, unless the contents of the 
field concerned happen to be identical to the initial 
value.

Regards,

Subramanian V.

Read only

0 Likes
3,360

Hello Joseph,

Just try one thing out - include the write statements in the subroutine itself. For example,


LOOP AT it_resb.

  ................................
  ................................
  ................................
  ................................

  AT END OF matnr.

    READ TABLE it_resb INDEX sy-tabix.
    SUM.
    l_bdmng = it_resb-bdmng.

    PERFORM bom_explode.

    WRITE: sy-uline.

  ENDAT.

ENDLOOP.


FORM bom_explode .

  CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
    EXPORTING
      .....      
      .....
      .....
    TABLES
      stb = stb
      matcat = matcat
    EXCEPTIONS
      .....      
      .....

  IF sy-subrc <> 0.
  ELSE.
    WRITE:/ sy-uline.
  ENDIF.

    LOOP AT stb.
      WRITE:/ sy-vline,stb-idnrk,stb-mnglg.
    ENDLOOP.

endform.

If that still doesn't work, then please paste your entire code here in the forum. We will be able to help you better.

Also, please note that the ON CHANGE OF block will fail in some cases eg: where the matnr is initial for the first (few) loop pass(es).

Hope to see your problem resolved.

Regards,

Anand Mandalika.

Read only

0 Likes
3,360

Dear Subramanian,

If on change makes the problem, how its working in Debugging?

And as you said i have tried by using at end of also. it does nt work.

To use function modules, whether we require some authorization?

Regards,

Lijo Joseph

Read only

0 Likes
3,360

Hello Joseph,

It has got nothing to do with authorizations. If you are saying that it is working in the debug-mode, it means that you have the authorizations required.

Hope that's clear.

Also please refer to my post below.

Regards,

Anand Mandalika.

P.S. : As and when you read a response, if you like it, please reward the points to the person posting the message. Click the yellow icon in the Post's header to do that.

Read only

0 Likes
3,360

As Anand said, it has nothing to do with authorization as its working in debug mode.

i thinks its time that you have to provide us the full code here to analyze the issue.

Regards

Raja

Read only

0 Likes
3,360

Hi Lijo,

I suggest you copy-paste the program here. I do not have the answer to the question "How is this 'On Change Of' working properly in debugging mode?". Probably one of those weird days.

As Anand has already said, there is no authorisation problem. Had this been an issue, even in debugging, it would not work. First , you need to remove the floating theory that, ABAP compiler has dual roles. (If this really is true, my goodness, can't even imagine..)

Regards,

Subramanian V.

Read only

0 Likes
3,360

Hi friends, here is the code.

REPORT zpp_cut_mat_issue LINE-SIZE 130 LINE-COUNT 65(3) NO STANDARD PAGE HEADING .

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

*Tables

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

TABLES : resb,makt,marc,afko,mara,aufk.

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

*Inputs

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

*PARAMETERS :

*Lead Production Order No.

  • P_AUFNR LIKE AFPO-AUFNR OBLIGATORY.

SELECT-OPTIONS :

*From No. to No.

s_matnr FOR resb-matnr ,

s_bdter FOR resb-bdter , "

s_ekgrp FOR marc-ekgrp,

s_mtyp FOR mara-extwg NO-EXTENSION NO INTERVALS ," TYPE C OBLIGATORY.

s_aufnr FOR resb-aufnr, "production order

s_dispo FOR marc-dispo, "MRP type

s_erdat FOR aufk-erdat. "prdn order creation date

PARAMETERS :

p_print TYPE c AS CHECKBOX,

p_sum TYPE c AS CHECKBOX.

RANGES : r_resb FOR afko-rsnum.

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

*Constants

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

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

*Type Pools

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

TYPE-POOLS : cs01.

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

*Data Declaration

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

DATA :

ismast TYPE cs01_mastb OCCURS 0 WITH HEADER LINE,

topmat TYPE cstmat OCCURS 0 WITH HEADER LINE,

stb TYPE stpox OCCURS 0 WITH HEADER LINE,

matcat TYPE cscmat OCCURS 0 WITH HEADER LINE,

dstst TYPE csdata-xfeld.

START-OF-SELECTION.

DATA it_resb LIKE resb OCCURS 0 WITH HEADER LINE.

SELECT aufnr matnr werks bdmng meins bdter INTO CORRESPONDING FIELDS OF TABLE it_resb FROM resb WHERE aufnr IN s_aufnr AND matnr IN s_matnr.

IF sy-subrc <> 0.

MESSAGE 'No Values Found' TYPE 'I'.

LEAVE LIST-PROCESSING.

ENDIF.

DELETE it_resb WHERE aufnr = space.

SORT it_resb BY matnr.

LOOP AT it_resb.

*Writing header

ON CHANGE OF it_resb-matnr.

FORMAT COLOR COL_HEADING ON.

WRITE:/ sy-vline,it_resb-matnr,sy-uline.

FORMAT COLOR OFF.

DATA: l_bdmng LIKE resb-bdmng.

ENDON.

*Writing Line Items.

WRITE:/ sy-vline,it_resb-aufnr,it_resb-bdmng,it_resb-meins.

AT END OF matnr.

*Writing Components Details

IF sy-subrc = 0.

READ TABLE it_resb INDEX sy-tabix.

SUM.

l_bdmng = it_resb-bdmng.

*Getting Components

PERFORM bom_explode.

*Displaying Components.

LOOP AT stb.

WRITE:/ sy-vline,stb-idnrk,stb-mnglg.

ENDLOOP.

ENDIF.

WRITE: sy-uline.

ENDAT.

ENDLOOP.

&----


*& Form bom_explode

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM bom_explode .

CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'

EXPORTING

aufsw = ' '

aumng = 0

capid = 'PP01'

datuv = sy-datum

ehndl = '1'

emeng = it_resb-bdmng

mktls = 'X'

mehrs = 'X'

mtnrv = it_resb-matnr

stpst = 0

svwvo = 'X'

werks = it_resb-werks

vrsvo = 'X'

IMPORTING

topmat = topmat

dstst = dstst

TABLES

stb = stb

matcat = matcat

EXCEPTIONS

alt_not_found = 1

call_invalid = 2

material_not_found = 3

missing_authorization = 4

no_bom_found = 5

no_plant_data = 6

no_suitable_bom_found = 7

conversion_error = 8

OTHERS = 9.

IF sy-subrc <> 0.

  • MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

  • WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ELSE.

WRITE:/ sy-uline.

ENDIF.

ENDFORM. " bom_explode

TOP-OF-PAGE.

CALL FUNCTION 'ZCA_REPORT_HEADER'

EXPORTING

hdval = 'Cutting List For Stores'

rpsize = 130

plant = 'BLR'.

Read only

ssimsekler
Product and Topic Expert
Product and Topic Expert
0 Likes
3,360

Hi Lijo

Firstly,

"ON CHANGE OF" has a buggy situation (Subramanian pointed before) as far as I know. Hence, just after your loop ends, insert the code:


CLEAR it_resb-matnr .
ON CHANGE OF it_resb-matnr .
ENDON .

This will clear the temporary work area that "ON CHANGE OF" uses.

Secondly,

I do not know what the "CS_BOM..." function is used for. Will a commit work statement after it do any work? I know, you do not seem updating anything, however although this is a very very poor possibility but the function may need it. So put a commit statement after calling your FM.

*--Serdar

Read only

0 Likes
3,360

Hello Joseph,

1.What's the sy-subrc check doing within the AT END OF block ?

2. It is my opinion that the program is not sufficiently modularized. The subroutine must have an interface and all the values used within it should be passed into it. Similarly, the values required outside the subroutine should be pssed out of it.

As I have mentioned in an earlier post, in this case, the write statements for the STB internal table are best written inside the subroutine.

Instead of trying to analyze why the program you have written is not working, (which is most probably because of some global data issue), it is better that you first try to modularize the subroutine properly. That would localize the area of error.

Hope this helps,

Regards,

Anand Mandalika.

Read only

0 Likes
3,360

Hi Serdar,

Thank you for your points. But my problem is not fully solved. Given function module explode the Bill of Material and list all the child materials.

As you said i have coded commit work after perform.

Now i am able to get last explosion result. but i want that explosion details for all the materials. I f i give two materials, i should get components for that materials.

i have commented "On change of" it is used just to display the material.

can you briefly tell me what Commit work do? and work and wait?

Read only

0 Likes
3,360

Serdar, well done. That is the only point, and I thought this FM does not save any data in database. I just checked the function module, and there is an EXPORT MEMORY also involved.

COMMIT WORK AND WAIT. All changes made to the database are made permanent. Sometimes when you write just a COMMIT statement, it sends this to an update process, which makes data permanent in the database at a later time.

Recently there has been a weblog on this.Also check that out.

Regards,

Subramanian V.

Read only

0 Likes
3,360

Hi Joseph,

One last thing that I can think of. When you execute the report, please give the material number as non-initial. The problem could be that you are getting the correct result, but the list output is tricky - since there can be a few entries where the MATNR is blank. For them, you are unable to see the components.

Also please note that the program is working perfectly as intended when I run it. So see if the data itself is problematic.

Regards,

Anand Mandalika.

Read only

0 Likes
3,360

Hi Friends,

I am giving only two materials as input. and it works well in Debugging.

I mean Pressing F6 throught the execution. It give desired output.

One thing i have noticed is if i remove top-of-page, it works fine.

top of page is having a function module which i am using for getting a desired header for the report.

I have removed if sy-subrc. any more corrections to be done to get the desired output?

Hi friends, As per serdar i have put one commit after function module which i call under top-of-page.

It solved my problem. thank you to all friends who helped me in this.

If i have forgotten to assign points, please forgive me.

regards,

Lijo Joseph

Message was edited by: lijo joseph

Read only

0 Likes
3,360

This certainly has been the entertainment of the day. Lijo, just clarify one point for me :

a) Does the FM BOM which you call, save data in the database ?

b) Does the 'Z' Function module that you have called, save data in the database ?

Regards,

Subramanian V.

Read only

0 Likes
3,360

Hello Subramaniam,

That is exactly what's haunting me. I'm still not able to fathom how the commit statement had helped resolve the problem. When it has been mentioned clearly that the FM is giving the desired result into the internal table (on pressing F6), then ho will a COMMIT statement at a later point resolve the data issue.

Also, what exactly are you hinting at when you ask if the 'Z' FM is saving any data to the database? Whether it does or doesn't, how would the output be manipulated (I mean, how does it influence the contents of the internal table in the program)?

Your answer will certainly clear some of my confusion.

Regards,

Anand Mandalika.

Read only

0 Likes
3,360

Hi Poornanand,

From Lijo's last post, it is clear that a COMMIT statement has been written. In that post, it is also mentioned that this COMMIT is written in the event TOP-OF-PAGE. From the code, we see that the 'Z' function module is called in the event TOP-OF-PAGE, not the SAP FM. So I am a little confused, whether the SAP FM saves the data in the database or the 'Z' FM saves the data in the database.

You have also mentioned that you have tried this program and it works perfectly fine. So it again points that the 'Z' FM is what has the problem. I am not sure for that matter.

Now to come to the question: How does it influence the contents of the internal table in the program ? God only knows.

If TOP-OF-PAGE does not fire properly, the other contents in that list would not come properly. So I am still thinking the mystery is in that 'Z' FM and the problem would have been solved not by that mysterious COMMIT but by commenting the TOP-OF-PAGE.

Many questions are still in my mind, but as I was figuring out one of the many answered questions in SDN, one person asked, the question is answered, why bother ? So there.

Regards,

Subramanian V.

Read only

Former Member
0 Likes
3,360

Hi Joseph,

I know that this has been answered already but I am curious like others to find out why such a simple program has to become a complicated one. We used the function module CS_BOM_EXPL_MAT_V2 a lot and we didn't get any problem.

If you pasted the code correctly, I see a problem with a statement right before your ENDAT statement and after the ENDLOOP of stb. The statement is

write: sy-uline.

This will overwrite the last written line in your output as you are not writing the ULINE on a new line, but writing it on the same line.

Also, RESB stores reservations for all the components after BOM explosion, so your call to BOM explosion, in all probability will return only one material, if the material is the lowest component, and if the material is a sub-assembly then you may get more than one record in your internal table 'stb'.

Now here are some suggestions for your code.

Change the statement 'WRITE: ULINE.' to 'WRITE:/ ULINE.'.

You are not refreshing the contents of your internal table 'stb', before the call to the BOM explosion FM. Please do that to avoide any leftovers.

Please let me know if this helps.

Srinivas

Read only

0 Likes
3,360

Dear Frinds,

Though my problem is solved, i feel it is not solved in right way. I am not updating any database. its purely a report.

Srinivas,

I have used BOM FM in other reposrts. i didnt see any problems. So its purely related to my coding.

Where ? that is the question.

I have tried as per you said but that is not having any effect.

Friends, please give Reason if you are able to find it.

Read only

0 Likes
3,360

Paste the new working code of your program.

Regards,

Subramanian V.

Read only

0 Likes
3,360

REPORT zpp_cut_mat_issue LINE-SIZE 130 LINE-COUNT 65(3) "LINE-COUNT 90(3)

NO STANDARD PAGE HEADING .

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

*Tables

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

TABLES : resb,makt,marc,mara,aufk.

DATA: l_bdmng LIKE resb-bdmng.

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

*Inputs

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

*PARAMETERS :

*Lead Production Order No.

  • P_AUFNR LIKE AFPO-AUFNR OBLIGATORY.

SELECT-OPTIONS :

*From No. to No.

s_matnr FOR resb-matnr ,

s_bdter FOR resb-bdter , "

s_ekgrp FOR marc-ekgrp,

s_mtyp FOR mara-extwg NO-EXTENSION NO INTERVALS ," TYPE C OBLIGATORY.

s_aufnr FOR resb-aufnr, "production order

s_dispo FOR marc-dispo, "MRP type

s_erdat FOR aufk-erdat, "prdn order creation date

s_werks for resb-werks.

*Raw Material /Assembly

RANGES : r_resb FOR afko-rsnum.

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

*Constants

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

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

*Type Pools

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

TYPE-POOLS : cs01.

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

*Data Declaration

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

DATA :

ismast TYPE cs01_mastb OCCURS 0 WITH HEADER LINE,

topmat TYPE cstmat OCCURS 0 WITH HEADER LINE,

stb TYPE stpox OCCURS 0 WITH HEADER LINE,

matcat TYPE cscmat OCCURS 0 WITH HEADER LINE,

dstst TYPE csdata-xfeld.

START-OF-SELECTION.

  • DATA it_resb LIKE resb OCCURS 0 WITH HEADER LINE.

DATA: BEGIN OF it_resb OCCURS 0,

matnr LIKE resb-matnr,

aufnr LIKE resb-aufnr,

bdmng LIKE resb-bdmng,

meins LIKE resb-meins,

bdter LIKE resb-bdter,

werks LIKE resb-werks,

pmatnr LIKE afpo-matnr,

pmaktx LIKE makt-maktx,

sbmng LIKE afko-sbmng,

baugr LIKE resb-baugr,

END OF it_resb.

*Variables

DATA l_lead_aufnr LIKE afpo-aufnr.

DATA l_pmatnr LIKE afpo-matnr.

DATA l_sbmng LIKE afko-sbmng.

DATA l_sbmeh LIKE afko-sbmeh.

DATA l_slno TYPE i.

data l_labst like mard-labst.

SELECT aufnr matnr werks bdmng meins bdter baugr INTO CORRESPONDING FIELDS OF TABLE it_resb FROM resb

WHERE aufnr IN s_aufnr AND matnr IN s_matnr and werks in s_werks

ORDER BY baugr.

IF sy-subrc <> 0.

MESSAGE 'No Values Found' TYPE 'I'.

LEAVE LIST-PROCESSING.

ENDIF.

DELETE it_resb WHERE aufnr = space.

LOOP AT it_resb.

SELECT SINGLE lead_aufnr sbmng sbmeh INTO (l_lead_aufnr,l_sbmng,l_sbmeh) FROM afko WHERE aufnr = it_resb-aufnr.

SELECT SINGLE matnr INTO it_resb-pmatnr FROM afpo WHERE aufnr = l_lead_aufnr.

SELECT SINGLE maktx INTO it_resb-pmaktx FROM makt WHERE matnr = it_resb-pmatnr.

MODIFY it_resb TRANSPORTING pmatnr pmaktx.

ENDLOOP.

SORT it_resb BY matnr baugr pmatnr .

LOOP AT it_resb.

ON CHANGE OF it_resb-matnr.

FORMAT COLOR COL_HEADING ON.

WRITE:/ sy-uline.

WRITE:/ sy-vline,it_resb-matnr,it_resb-baugr,it_resb-meins,sy-uline.

FORMAT COLOR OFF.

l_slno = 1.

ENDON.

WRITE:/1 sy-vline,2(3) l_slno,sy-vline,(12) it_resb-aufnr,sy-vline,it_resb-bdmng,it_resb-meins,it_resb-baugr,it_resb-pmaktx.

l_slno = l_slno + 1.

AT END OF matnr .

READ TABLE it_resb INDEX sy-tabix.

SUM.

l_bdmng = it_resb-bdmng.

WRITE:/ sy-uline.

FORMAT COLOR COL_TOTAL ON.

WRITE:/ 'Total:',l_bdmng.

FORMAT COLOR OFF.

PERFORM bom_explode .

ENDAT.

ENDLOOP.

&----


*& Form bom_explode

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM bom_explode .

CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'

EXPORTING

aufsw = ' '

aumng = 0

capid = 'PP01'

datuv = sy-datum

ehndl = '1'

emeng = it_resb-bdmng

mktls = 'X'

mehrs = 'X'

mtnrv = it_resb-matnr

stpst = 0

svwvo = 'X'

werks = it_resb-werks

vrsvo = 'X'

IMPORTING

topmat = topmat

dstst = dstst

TABLES

stb = stb

matcat = matcat

EXCEPTIONS

alt_not_found = 1

call_invalid = 2

material_not_found = 3

missing_authorization = 4

no_bom_found = 5

no_plant_data = 6

no_suitable_bom_found = 7

conversion_error = 8

OTHERS = 9.

IF sy-subrc <> 0.

  • MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

  • WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ELSE.

WRITE:/ sy-uline.

LOOP AT stb.

WRITE:/ stb-idnrk,stb-menge,stb-meins,stb-mnglg,stb-meins,l_labst.

ENDLOOP.

WRITE:/ sy-uline.

SKIP 1.

ENDIF.

ENDFORM. " bom_explode

TOP-OF-PAGE.

CALL FUNCTION 'ZCA_REPORT_HEADER'

EXPORTING

hdval = 'Cutting List For Stores'

rpsize = 130

plant = 'BLR'.

COMMIT WORK.

Read only

0 Likes
3,360

Apart from the COMMIT WORK , I do not see any changes in the program. Have you done any changes , any changes at all ,apart from putting the line COMMIT WORK ?

And according to you, if you remove that COMMIT WORK, program does not work. Wow. Just amazing.

What does the 'Z' FM do ? Does it store any value in any tables ?

COMMIT WORK makes changes in database permanent and apart from that , I am not aware if it does any extra activities, as making display visible/invisible.

Regards,

Subramanian V.

P.S. - I think your program would be successful in making me crazy

Read only

0 Likes
3,360

Dear Subramanian,

I have not done any changes apart from Commit Work.

My function module doesn't make any database change. Since we will have so many reports, i have created a common Report header which can be used for all the report. It takes Report length and according to that it align the header and all other data.

If i remove that FM it works. If i put Commit work also it works. But i am still not clear about the concept though my problem is solved.

I will be thankfull to everybody for their precious Suggestion.

Regards,

Lijo Joseph

Read only

0 Likes
3,360

Just thinking aloud, why don't you try debugging at the commit wok statement. You need to use Update Debugging.

Here's another way which you can gain a better understanding about this program.

While you are in the debug mode, in general there are 4 icons you can see in the application toolbar (single step, execute, return, continue). But If you are debugging a report program which ahs a list output, then immediately after the first WRITE statement in your program, the debugger shows another icon on the toolbar. If you click this icon, you will be able to see the list output that has been generated up to that point in debugging. Please examine the output at various stages carefully and verify whether it is as expected.

Be expecially careful with the Z function Module. Debug with and without that and compare the list outputs at various stages and see if you can find something.

Please let us know if you find something.

Regards,

Anand Mandalika.

Read only

0 Likes
3,360

Now that you have isolated the problem to your TOP-OF-PAGE, Z function module, take a closer look at your Z function module's 'write' statements. Also, sometimes a format reset after the call to your Z function module might work.

Also, can you confirm that you are loosing data only when the top-of-page is triggered, no other time?

I am inclined to believe that there is some 'write' statement in the Z function module that is overwriting your lines or there is some format statement that is making your line disappear.

Please check in debugging, whether you see the list line before and after top-of-page.

Regards,

Srinivas