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

Selection Screen Validations for Plant and Company Code

Former Member
0 Likes
2,617

Hi friends,

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01. "Sender

PARAMETERS : p_bukrs0 LIKE t001-bukrs OBLIGATORY.

SELECT-OPTIONS : s_werks0 FOR t001w-werks OBLIGATORY.

SELECTION-SCREEN END OF BLOCK b1.

is my code and now i need to validate these seperately for plant, company code and for plant/company code combinations in single range objects to determine their validity in the AT SELECTION_SCREEN event.

CAn anyone send me the code for this.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,581

Hi,

At SELECTION-SCREEN .

select single bukrs from t001 where bukrs eq p_bukrs .

if sy-subrc <> 0.

Messgae e001 with 'Code not found' .

endif.

select single werks from t001 where werks eq p_werks .

if sy-subrc <> 0.

Messgae e001 with 'Plant not found' .

endif.

Will this piece work for you ?

Regards,

Varun .

Hi friends,

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01. "Sender

PARAMETERS : p_bukrs0 LIKE t001-bukrs OBLIGATORY.

SELECT-OPTIONS : s_werks0 FOR t001w-werks OBLIGATORY.

SELECTION-SCREEN END OF BLOCK b1.

is my code and now i need to validate these seperately for plant, company code and for plant/company code combinations in single range objects to determine their validity in the AT SELECTION_SCREEN event.

CAn anyone send me the code for this.

8 REPLIES 8
Read only

Former Member
0 Likes
1,582

Hi,

At SELECTION-SCREEN .

select single bukrs from t001 where bukrs eq p_bukrs .

if sy-subrc <> 0.

Messgae e001 with 'Code not found' .

endif.

select single werks from t001 where werks eq p_werks .

if sy-subrc <> 0.

Messgae e001 with 'Plant not found' .

endif.

Will this piece work for you ?

Regards,

Varun .

Read only

0 Likes
1,581

Hi Varun,

Thanks for the information, but i want the code for company code and plant combination. U have sent me validation seperately

Read only

0 Likes
1,581

Hi Check this.

At selection-screen.

Select single * from t001k

where bukrs = p_bukrs

and bwkey in s_werks.

if sy-subrc ne 0.

  • Error message.

Endif.

Hope this helps.

Read only

Former Member
0 Likes
1,581

HI GOPI,

if not p_bukrs is initial.

select bukrs from t001 upto 1 rows

where bukrs = p_bukrs.

if sy-subrc <> 0.

message e001(ZZ).

endif.

endif.

if not p_werks is initial.

select werks from t001 upto 1 rows

where bukrs = p_werks.

if sy-subrc <> 0.

message e001(ZZ).

endif.

endif.

<b>select bukrs werks from t001 upto 1 rows

where bukrs in p_bukrs

and werks = p_werks.

if sy-subrc <> 0.

message e003(ZZ).

endif.</b>

hope this helps,

do reward if it helps,

priya.

Message was edited by: Priya

Read only

Former Member
0 Likes
1,581

Hi gopi,

check this:

AT SELECTION-SCREEN .

SELECT SINGLE MATNR

FROM MARA

INTO V_MATNR

WHERE MATNR IN S_MATNR.

if sy-subrc <> 0.

message e000 with 'incorrect data'.

endif.

SELECT SINGLE WERKS

FROM T001W

INTO V_WERKS

WHERE WERKS IN S_WERKS.

if sy-subrc <> 0.

message e000 with 'incorrect data'.

endif.

SELECT SINGLE LGORT

FROM T001L

INTO V_LGORT

WHERE LGORT IN S_LGORT.

if sy-subrc <> 0.

message e000 with 'incorrect data'.

endif.

SELECT SINGLE MATNR

WERKS

LGORT

FROM MARD

INTO (V_MATNR, V_WERKS,V_LGORT)

WHERE MATNR IN S_MATNR AND

WERKS IN S_WERKS AND

LGORT IN S_LGORT.

if sy-subrc <> 0.

message e000 with 'incorrect data'.

endif.

do reawrd if it helps.

regards,

keerthi.

Read only

ibrahim_u
Active Participant
0 Likes
1,581

at selection-screen on block b1.
  loop at s_werks0.
    if s_werks0-option eq 'BT'.
      select single * from t001w where bukrs eq p_bukrs0
                                   and werks between s_werks0-low and s_werks0-high.
      if not sy-subrc is initial.
        message e*******
      endif.
    elseif s_werks0-option eq 'EQ'.
      select single * from t001w where bukrs eq p_bukrs0
                                   and werks eq s_werks0-low.
      if not sy-subrc is initial.
        message e*******
      endif.
    elseif s_werks0-option eq 'NE'.
      select single * from t001w where bukrs eq p_bukrs0
                                   and werks eq s_werks0-low.
      if sy-subrc is initial.
        message e*******
      endif.
    endif.
  endloop.

or


at selection-screen on block b1.
  select single * from t001w where bukrs eq p_bukrs0
                               and werks in s_werks0.
  if not sy-subrc is initial.
    message e********.
  endif.

ibrahim

Read only

Former Member
0 Likes
1,581

HI Gopi,

At selection-screen.

IF NOT P_BUKRS IS INITIAL.

SELECT BUKRS UPTO 1 ROWS

INTO V_BUKRS

FROM TOO1 WHERE

BUKRS = P_BUKRS.

IF SY-SUBRC <> 0.

MESSAGE E001.

ENDIF.

ENDIF.

IF NOT S_WERKS IS INITIAL.

SELECT WERKS UPTO 1 ROWS

INTO V_WERKS

FROM T001W

WHERE WERKS IN S_WERKS.

IF SY-SUBRC <> 0.

MESSAGE E002.

ENDIF.

ENDIF.

REGARDS,

LAXMI.

Read only

Former Member
0 Likes
1,581

closing the thread