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

MB90 related problem

former_member187748
Active Contributor
0 Likes
3,044

Hi all,

i have a need to stop printing my smartform, according to the criteria that for a particular Ref. Doc., i have to see the list of Material Document.

If the last value of Material Document have a movement type "102", then it wouldn't get printed.

I have written this code but not getting desired result, please anyone correct my code(after seeing the screenshot).

DATA : ls_mseg type mseg,

        it_mseg type mseg,

        it_mseg1 type mseg,

        it_mseg2 type mseg.

LOOP AT RG_MBLNR.

clear: ls_mseg.

select single * from mseg into ls_mseg

   where mblnr in RG_MBLNR.

select single lfbnr from mseg into it_mseg where lfbnr = mseg-belnr.

select * from mseg into it_mseg1 where lfbnr = mseg-lfbnr.

select max( belnr ) from mseg into it_mseg2 where belnr = RG_MBLNR.

ENDSELECT.      

   IF sy-subrc eq 0.

     DELETE RG_MBLNR.

   ENDIF.

ENDLOOP.

1 ACCEPTED SOLUTION
Read only

former_member209120
Active Contributor
0 Likes
2,758

Hi Sanjiv,

First put break point in that enhancement check what your are getting in RG_MBLNR and ls_mseg-bwart

DATA : ls_mseg type mseg.

Break-point.

LOOP AT RG_MBLNR.

clear: ls_mseg.

select single * from mseg into ls_mseg where mblnr in RG_MBLNR.

  IF ls_mseg-bwart = '102'.

     DELETE RG_MBLNR.

   ENDIF.

ENDLOOP.

Hi all,

i have a need to stop printing my smartform, according to the criteria that for a particular Ref. Doc., i have to see the list of Material Document.

If the last value of Material Document have a movement type "102", then it wouldn't get printed.

I have written this code but not getting desired result, please anyone correct my code(after seeing the screenshot).

DATA : ls_mseg type mseg,

        it_mseg type mseg,

        it_mseg1 type mseg,

        it_mseg2 type mseg.

LOOP AT RG_MBLNR.

clear: ls_mseg.

select single * from mseg into ls_mseg

   where mblnr in RG_MBLNR.

select single lfbnr from mseg into it_mseg where lfbnr = mseg-belnr.

select * from mseg into it_mseg1 where lfbnr = mseg-lfbnr.

select max( belnr ) from mseg into it_mseg2 where belnr = RG_MBLNR.

ENDSELECT.      

   IF sy-subrc eq 0.

     DELETE RG_MBLNR.

   ENDIF.

ENDLOOP.

10 REPLIES 10
Read only

former_member187748
Active Contributor
0 Likes
2,758

Hi All,

please see this edited code, and do the needful

DATA : ls_mseg type mseg,

        it_mseg type mseg,

        it_mseg1 type mseg,

        it_mseg2 type mseg.

LOOP AT RG_MBLNR.

clear: ls_mseg.

select single * from mseg into ls_mseg

   where mblnr in RG_MBLNR.

select single lfbnr from mseg into it_mseg where lfbnr = mseg-belnr.

select * from mseg into it_mseg1 where lfbnr = mseg-lfbnr.

select max( belnr ) from mseg into it_mseg2 where belnr = RG_MBLNR

                                             AND bwart = '102'.

ENDSELECT.      

   IF sy-subrc eq 0.

     DELETE RG_MBLNR.

   ENDIF.

ENDLOOP.

Read only

former_member209120
Active Contributor
0 Likes
2,759

Hi Sanjiv,

First put break point in that enhancement check what your are getting in RG_MBLNR and ls_mseg-bwart

DATA : ls_mseg type mseg.

Break-point.

LOOP AT RG_MBLNR.

clear: ls_mseg.

select single * from mseg into ls_mseg where mblnr in RG_MBLNR.

  IF ls_mseg-bwart = '102'.

     DELETE RG_MBLNR.

   ENDIF.

ENDLOOP.

Read only

former_member585060
Active Contributor
0 Likes
2,758

Hi,

   

Is this code used in any BADI implementation or a custom program from where you are printing.

DATA : lt_mseg    TYPE STANDARD TABLE OF mseg,

             wa_mseg TYPE mseg,

            wa_mblnr TYPE mseg.

SELECT SINGLE *

                             FROM mseg

                              INTO wa_mblnr

                              WHERE mblnr = rg_mblnr.

IF sy-subrc = 0.

SELECT *

                FROM mseg

                 INTO TABLE lt_mseg

                 WHERE belnr = wa_mblnr-belnr.

IF sy-subrc = 0.

   SORT lt_mseg BY mblnr DESCENDING belnr.

CLEAR : wa_mblnr.

READ TABLE lt_msge INTO wa_mblnr INDEX 1.

IF sy-subrc = 0.

**** Verify the wa_mblnr-bwart value here, if 102 don' issue print. 

ENDIF.

ENDIF.

Thanks & Regards

Bala Krishna

Read only

0 Likes
2,758

Hi Bala Krishna,

He is using in   MM70AMEA Enhancement.

Read only

0 Likes
2,758

Hi Bala,

i am doing an enhancement in MB90, in which it is desired that when we enter any Document No. in MB90, it is referred as MBLNR, now whenever any PO gets revarsal, then for that it forms an reference

no, now according to the screenshot, there are single REF. DOC. for which there are many Material Doc. exist, now i need to select the last MATERIAL DOCUMENT, and if the value of it is SAME as that

of the MBLNR value , we have entered in MB90, and its bwart is "102", then it wouldn't gets printed.

If the value of MBLNR we entered in MB90 is same as that of the last value in BELNR and the movement type is "101", then it gets printed.

From my last post i came to know that the value we entered as Material Doc. in MB90 is in DISP-MBLNR, but when i debug MB90, i get MBLNR in RG_MBLNR, so i have written select -option accordingly.

Seeing my present scenario please sujjest me the code that will fill my requirement.

Read only

0 Likes
2,758

Hi Sanjeev,

Why are you looking for the last material document? You should only check if that particular document is reversed or not. Your logic will not work if you do the partial GR's.

As per your screenshot below are your material documents.

5..466 101

5..467 102

5..468 101

5..469 102

5..470 101

Logically speaking, if you run MB90 for 5..466 or 5..468, it shouldn't print because they all were reversed. If you run MB90 for 5..470, it should print because it is not reversed.

However, if you still want to work with your logic, you can get the list of material documents from EKBE table. Just get the PO number(EKBE-EBELN) and line item number (EKNE-EBELP) from EKBE where BELNR = MBLNR. Once you found the PO and Line item number, get the list of relevant material documents from the same table EKBE where EBELN and EBELP from the previous query.

Regards,

Asik.

Read only

former_member209120
Active Contributor
0 Likes
2,758

DATA : It_mseg type mseg,

           wa_mseg type mseg.

Select * from mseg into table it_mseg where mblnr =  rg_mblnr and mjahr = pm_mjahr.

Loop at it_mseg into wa_mseg.

  IF wa_mseg-bwart = '102'.

     DELETE RG_MBLNR.   

   ENDIF.

clear wa_mseg.    

ENDLOOP.

Read only

0 Likes
2,758

Hello Ramesh,

please tell me what is the need of mjahr field in this. i am not getting your points properly,

please specify clearly, why you have taken it into consideration.

Read only

0 Likes
2,758

Hi Sanjeev,

mjahr field specifies year of the material document

Read only

0 Likes
2,756

Hello Ramesh,

i know its Material Document Year, but  what is its use.

See my requirment is that"when i will enter Material Doc. No. in MB90, it will see its ref. doc. field,

then through this ref. doc, it will see how many Material Doc for this are there (see the screenshot), then it will go for the last Material Doc., if the value of the Material Doc. i enters in MB90 is equal to last Material Doc. in the table

(as in screenshot), then only my smartform gets printed,otherwise not".

For this please do needful.