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

Formatting Output Based on Data in TVARVC

Hi Guys

In the below program I need to highlight lines of output where the plant complies to the rules green and those that do not in red in a variant called check plant.

Here are the values.

S 0000 I EQ 1000

S 0001 I EQ 3000

S 0002 I BT 2000 2500

S 0003 I BT 6100 6150

S 0004 E EQ 2300

S 0005 E EQ 6101

I have tried to achieve this in the code below but it doesn't work properly some plants are highlighted green when they should be red and vice versa. Please could you help me with the correct logic.

REPORT ZTREVOR_CHECK_VARIANT message-id ZTREVOR_MSG_CLASS1.

data: it_makt type standard table of makt,

wa_makt type makt,

it_mard type standard table of mard,

wa_mard type mard,

it_t001w type standard table of t001w,

wa_t001w type t001w.

Data: it_mard_distinct type standard table of mard,

v_werks type werks,

v_matnr type matnr.

data: it_tvarvc type standard table of tvarvc,

wa_tvarvc type tvarvc.

CONSTANTS : C_VARNAME TYPE rvari_vnam value 'CHECK_PLANT'.

select-options : s_matnr for v_matnr no intervals no-extension,

s_spras for wa_makt-spras no intervals no-extension.

AT SELECTION-SCREEN.

SELECT single matnr from mara into v_matnr WHERE matnr in s_matnr.

IF sy-subrc IS NOT INITIAL.

MESSAGE w000 with s_matnr-low display like 'I'.

ENDIF.

start-of-selection.

select * from makt into table it_makt where matnr in s_matnr and spras in s_spras.

select * from mard into table it_mard where matnr in s_matnr.

select * from tvarvc into table it_tvarvc where name = C_VARNAME.

end-of-selection.

IF it_mard is not initial.

sort it_mard by werks.

LOOP AT it_mard INTO wa_mard.

IF wa_mard-werks NE v_werks.

APPEND wa_mard TO it_mard_distinct.

ENDIF.

v_werks = wa_mard-werks.

ENDLOOP.

select * from t001w into table it_t001w for all entries in it_mard_distinct where werks = it_mard_distinct-werks.

endif.

write : at / 'Material' color col_positive,

10 'Description' color col_positive,

30 'Plant' color col_positive,

60 'Plant Name' color col_positive.

LOOP AT it_mard_distinct into wa_mard.

READ table it_makt into wa_makt with key matnr = wa_mard-matnr binary search.

READ table it_t001w into wa_t001w with key werks = wa_mard-werks.

READ TABLE it_tvarvc into wa_tvarvc with key low = wa_mard-werks.

if wa_tvarvc is not initial.

FORMAT color = 5.

else.

FORMAT color = 6.

endif.

write : at / wa_makt-matnr,

10 wa_makt-maktx,

30 wa_mard-werks,

60 wa_t001w-name1.

endloop.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 07, 2011 at 02:47 PM

    you are crosschecking with TVARVC the wrong way.

    At least you cant check for equality.

    See in tvarvc there are not only single variables (parameters), but also ranges (select-options).

    I assume the small list in the top of your post is an excerpt of your TVARVC entries for plant checks.

    As you can see there are select option using option BT (between)

    when you select on tvarvc with LOW field you will never get those which are between the customized entries.

    what you need to do is select your TVARVC entries, make a range out of it and check your plant like following:

    loop at it_mard_distinct into wa_mard.
      If wa_mard-werks IN range_plants.
        colour green.
      else.
        colour red.
      endif.
    endloop.
    

    hope you could follow me.

    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.