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

problem in the code

Hi,

I am working on a code and it is giving problem that where the Work center field is empty it is making the last field repeated having the Work Center . here 's d code :-

LOOP AT T_MAPL INTO W_MAPL.

LOOP AT T_PLAS INTO W_PLAS WHERE PLNAL = W_MAPL-PLNAL AND PLNNR = W_MAPL-PLNNR.

W_FTAB6-PLNKN = W_PLAS-PLNKN.

LOOP AT T_PLPO INTO W_PLPO WHERE PLNNR = W_PLAS-PLNNR AND PLNKN = W_PLAS-PLNKN.

W_FTAB6-MATNR = W_MAPL-MATNR.

W_FTAB6-PLNTY = W_MAPL-PLNTY.

W_FTAB6-PLNAL = W_MAPL-PLNAL.

W_FTAB6-WERKS = W_MAPL-WERKS.

READ TABLE T_PLKO INTO W_PLKO WITH KEY PLNAL = W_MAPL-PLNAL PLNNR = W_MAPL-PLNNR.

W_FTAB6-KTEXT = W_PLKO-KTEXT.

W_FTAB6-PLNNR = W_PLPO-PLNNR.

W_FTAB6-VORNR = W_PLPO-VORNR.

W_FTAB6-LTXA1 = W_PLPO-LTXA1.

W_FTAB6-KTSCH = W_PLPO-KTSCH.

W_FTAB6-ARBID = W_PLPO-ARBID.

W_FTAB6-BMSCH = W_PLPO-BMSCH.

W_FTAB6-MEINH = W_PLPO-MEINH.

W_FTAB6-VGW04 = W_PLPO-VGW04.

W_FTAB6-VGE04 = W_PLPO-VGE04.

READ TABLE T_CRHD INTO W_CRHD WITH KEY OBJID = W_PLPO-ARBID.

W_FTAB6-ARBPL = W_CRHD-ARBPL.

W_FTAB6-VERWE = W_CRHD-VERWE.

W_FTAB6-OBJTY = W_CRHD-OBJTY.

W_FTAB6-OBJID = W_CRHD-OBJID.

READ TABLE T_CRTX INTO W_CRTX WITH KEY OBJID = W_CRHD-OBJID.

W_FTAB6-KTEXT_UP = W_CRTX-KTEXT_UP.

READ TABLE T_MARC INTO W_MARC WITH KEY MATNR = W_MAPL-MATNR.

W_FTAB6-LGPRO = W_MARC-LGPRO.

APPEND W_FTAB6 TO T_FTAB6.

ENDLOOP.

ENDLOOP.

ENDLOOP.

Plzz provide me guidlines that how should i remove the filling of the records which does not have the Work Center. (ARBPL)

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Nov 11, 2008 at 05:12 AM

    LOOP AT T_MAPL INTO W_MAPL.
    
    LOOP AT T_PLAS INTO W_PLAS WHERE PLNAL = W_MAPL-PLNAL AND PLNNR = W_MAPL-PLNNR.
    W_FTAB6-PLNKN = W_PLAS-PLNKN.
    
    LOOP AT T_PLPO INTO W_PLPO WHERE PLNNR = W_PLAS-PLNNR AND PLNKN = W_PLAS-PLNKN.
    W_FTAB6-MATNR = W_MAPL-MATNR.
    W_FTAB6-PLNTY = W_MAPL-PLNTY.
    W_FTAB6-PLNAL = W_MAPL-PLNAL.
    W_FTAB6-WERKS = W_MAPL-WERKS.
    
    READ TABLE T_PLKO INTO W_PLKO WITH KEY PLNAL = W_MAPL-PLNAL PLNNR = W_MAPL-PLNNR.
    
    W_FTAB6-KTEXT = W_PLKO-KTEXT.
    W_FTAB6-PLNNR = W_PLPO-PLNNR.
    W_FTAB6-VORNR = W_PLPO-VORNR.
    W_FTAB6-LTXA1 = W_PLPO-LTXA1.
    W_FTAB6-KTSCH = W_PLPO-KTSCH.
    W_FTAB6-ARBID = W_PLPO-ARBID.
    W_FTAB6-BMSCH = W_PLPO-BMSCH.
    W_FTAB6-MEINH = W_PLPO-MEINH.
    W_FTAB6-VGW04 = W_PLPO-VGW04.
    W_FTAB6-VGE04 = W_PLPO-VGE04.
    
    READ TABLE T_CRHD INTO W_CRHD WITH KEY OBJID = W_PLPO-ARBID.
    If Sy-subrc NE 0. "if no matching record found
     Exit. "Exit loop without appending the record
    Endif.
    W_FTAB6-ARBPL = W_CRHD-ARBPL.
    W_FTAB6-VERWE = W_CRHD-VERWE.
    W_FTAB6-OBJTY = W_CRHD-OBJTY.
    W_FTAB6-OBJID = W_CRHD-OBJID.
    
    READ TABLE T_CRTX INTO W_CRTX WITH KEY OBJID = W_CRHD-OBJID.
    W_FTAB6-KTEXT_UP = W_CRTX-KTEXT_UP.
    
    READ TABLE T_MARC INTO W_MARC WITH KEY MATNR = W_MAPL-MATNR.
    W_FTAB6-LGPRO = W_MARC-LGPRO.
    
    APPEND W_FTAB6 TO T_FTAB6.
    ENDLOOP.
    ENDLOOP.
    ENDLOOP.

    Plzz provide me guidlines that how should i remove the filling of the records which does not have the Work Center. (ARBPL)

    This will avoid appending of fields without a work center. Check this and revert back.

    Regards

    Karthik D

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 11, 2008 at 04:05 AM

    Hi,

    I don;t know the work center field name.......

    If the value is fetched through read statement, then check for sy-subrc.

    if sy-subrc eq 0.

    pass the work center value

    else.

    clear that field.

    endif.

    If the value is fetched through loop statement, then at the end of every loop pass, clear that workarea field.

    -SatyaPriya

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 11, 2008 at 04:07 AM

    Hi,

    u have to clear the field after before the endloop.

    
    LOOP AT T_MAPL INTO W_MAPL.
    
    LOOP AT T_PLAS INTO W_PLAS WHERE PLNAL = W_MAPL-PLNAL AND PLNNR = W_MAPL-PLNNR.
    W_FTAB6-PLNKN = W_PLAS-PLNKN.
    
    LOOP AT T_PLPO INTO W_PLPO WHERE PLNNR = W_PLAS-PLNNR AND PLNKN = W_PLAS-PLNKN.
    W_FTAB6-MATNR = W_MAPL-MATNR.
    W_FTAB6-PLNTY = W_MAPL-PLNTY.
    W_FTAB6-PLNAL = W_MAPL-PLNAL.
    W_FTAB6-WERKS = W_MAPL-WERKS.
    
    READ TABLE T_PLKO INTO W_PLKO WITH KEY PLNAL = W_MAPL-PLNAL PLNNR = W_MAPL-PLNNR.
    
    W_FTAB6-KTEXT = W_PLKO-KTEXT.
    W_FTAB6-PLNNR = W_PLPO-PLNNR.
    W_FTAB6-VORNR = W_PLPO-VORNR.
    W_FTAB6-LTXA1 = W_PLPO-LTXA1.
    W_FTAB6-KTSCH = W_PLPO-KTSCH.
    W_FTAB6-ARBID = W_PLPO-ARBID.
    W_FTAB6-BMSCH = W_PLPO-BMSCH.
    W_FTAB6-MEINH = W_PLPO-MEINH.
    W_FTAB6-VGW04 = W_PLPO-VGW04.
    W_FTAB6-VGE04 = W_PLPO-VGE04.
    
    READ TABLE T_CRHD INTO W_CRHD WITH KEY OBJID = W_PLPO-ARBID.
    W_FTAB6-ARBPL = W_CRHD-ARBPL.
    W_FTAB6-VERWE = W_CRHD-VERWE.
    W_FTAB6-OBJTY = W_CRHD-OBJTY.
    W_FTAB6-OBJID = W_CRHD-OBJID.
    
    READ TABLE T_CRTX INTO W_CRTX WITH KEY OBJID = W_CRHD-OBJID.
    W_FTAB6-KTEXT_UP = W_CRTX-KTEXT_UP.
    
    READ TABLE T_MARC INTO W_MARC WITH KEY MATNR = W_MAPL-MATNR.
    W_FTAB6-LGPRO = W_MARC-LGPRO.
    
    APPEND W_FTAB6 TO T_FTAB6.
    
    *"-----------------------------
    CLEAR: W_PLKO,
           W_CRHD,
           W_CRTX,
           W_MARC,
           W_FTAB6.
    *"-----------------------------
    ENDLOOP.
    ENDLOOP.
    ENDLOOP.
    

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      Use Below code, hope it will help u..

      LOOP AT T_MAPL INTO W_MAPL.

      W_FTAB6-MATNR = W_MAPL-MATNR.

      W_FTAB6-PLNTY = W_MAPL-PLNTY.

      W_FTAB6-PLNAL = W_MAPL-PLNAL.

      W_FTAB6-WERKS = W_MAPL-WERKS.

      LOOP AT T_PLAS INTO W_PLAS WHERE PLNAL = W_MAPL-PLNAL AND PLNNR = W_MAPL-PLNNR.

      W_FTAB6-PLNKN = W_PLAS-PLNKN.

      LOOP AT T_PLPO INTO W_PLPO WHERE PLNNR = W_PLAS-PLNNR AND PLNKN = W_PLAS-PLNKN.

      W_FTAB6-PLNNR = W_PLPO-PLNNR.

      W_FTAB6-VORNR = W_PLPO-VORNR.

      W_FTAB6-LTXA1 = W_PLPO-LTXA1.

      W_FTAB6-KTSCH = W_PLPO-KTSCH.

      W_FTAB6-ARBID = W_PLPO-ARBID.

      W_FTAB6-BMSCH = W_PLPO-BMSCH.

      W_FTAB6-MEINH = W_PLPO-MEINH.

      W_FTAB6-VGW04 = W_PLPO-VGW04.

      W_FTAB6-VGE04 = W_PLPO-VGE04.

      READ TABLE T_PLKO INTO W_PLKO WITH KEY PLNAL = W_MAPL-PLNAL PLNNR = W_MAPL-PLNNR.

      IF SY-SUBRC = 0.

      W_FTAB6-KTEXT = W_PLKO-KTEXT.

      ENDIF.

      READ TABLE T_CRHD INTO W_CRHD WITH KEY OBJID = W_PLPO-ARBID.

      IF SY-SUBRC = 0.

      W_FTAB6-ARBPL = W_CRHD-ARBPL.

      W_FTAB6-VERWE = W_CRHD-VERWE.

      W_FTAB6-OBJTY = W_CRHD-OBJTY.

      W_FTAB6-OBJID = W_CRHD-OBJID.

      ENDIF.

      READ TABLE T_CRTX INTO W_CRTX WITH KEY OBJID = W_CRHD-OBJID.

      IF SY-SUBRC = 0.

      W_FTAB6-KTEXT_UP = W_CRTX-KTEXT_UP.

      ENDIF.

      READ TABLE T_MARC INTO W_MARC WITH KEY MATNR = W_MAPL-MATNR.

      IF SY-SUBRC = 0.

      W_FTAB6-LGPRO = W_MARC-LGPRO.

      ENDIF.

      APPEND W_FTAB6 TO T_FTAB6.

      ENDLOOP.

      ENDLOOP.

      ENDLOOP.

      Regards,

      Meet Gohel

  • author's profile photo Former Member
    Former Member
    Posted on Nov 11, 2008 at 04:48 AM

    Hi,

    I think your problem will be solved with staypriyas solution. Check for sy-subrc after each read statement. For ex:

    READ TABLE T_CRHD INTO W_CRHD WITH KEY OBJID = W_PLPO-ARBID.
    
    if sy-subrc eq 0.
    
    W_FTAB6-ARBPL = W_CRHD-ARBPL.
    W_FTAB6-VERWE = W_CRHD-VERWE.
    W_FTAB6-OBJTY = W_CRHD-OBJTY.
    W_FTAB6-OBJID = W_CRHD-OBJID.
    
    endif.
    

    Regards,

    Swarna Munukoti.

    Edited by: Swarna Munukoti on Nov 11, 2008 5:48 AM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 11, 2008 at 05:45 AM

    Do the following correction:

    READ TABLE T_CRHD INTO W_CRHD WITH KEY OBJID = W_PLPO-ARBID.

    if sy-subrc = 0.

    W_FTAB6-ARBPL = W_CRHD-ARBPL.

    W_FTAB6-VERWE = W_CRHD-VERWE.

    W_FTAB6-OBJTY = W_CRHD-OBJTY.

    W_FTAB6-OBJID = W_CRHD-OBJID.

    endif.

    This should solve your problem.

    Regards,

    Prakash Pandey

    Add a comment
    10|10000 characters needed characters exceeded

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.