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

validation in report

Former Member
0 Likes
550

Hi experts,

i have developed a report for which in selection screen fields are material group and material number.now i have to write validation for this ie.i have to check

whether a particular material number exists in material group.if yes show o/p else it should display not exists.can any one help me.

Regards,

Ashok kumar

4 REPLIES 4
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
530

Try this.


report zrich_0001.

data: xmara type mara.

parameters: p_matnr type mara-matnr,
            p_matkl type mara-matkl.

at selection-screen.
  select single * from mara into xmara
         where matnr = p_matnr.
  if sy-subrc  <> 0.
    message e001(00)
       with 'Material does not exist'.
  endif.

  if xmara-matkl <> p_matkl.
    message e001(00)
    with 'Material does not exist within material group'.
  endif.

start-of-selection.

  write:/ xmara-matnr, xmara-matkl.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
530

hi,

Check the sy-subrc condition in the at selection-screen event.

Read only

Former Member
0 Likes
530

"----


  • AT SELECTION-SCREEN EVENT *

"----


AT SELECTION-SCREEN ON S_EBELN.

  • Subroutine to validate Purchase Document Number.

PERFORM VALIDATE_PD_NUM.

AT SELECTION-SCREEN ON S_LIFNR.

  • Subroutine to validate Vendor Number.

PERFORM VALIDATE_VEN_NUM.

AT SELECTION-SCREEN ON S_EKGRP.

  • Subroutine to validate Purchase Group.

PERFORM VALIDATE_PUR_GRP.

&----


*& Form VALIDATE_PD_NUM

&----


  • Subroutine to validate Purchase Document Number

----


  • There are no interface parameters to be passed to this subroutine.

----


FORM VALIDATE_PD_NUM .

IF NOT S_EBELN[] IS INITIAL.

SELECT EBELN " Purchase Document Number

FROM EKKO

INTO W_EBELN

UP TO 1 ROWS

WHERE EBELN IN S_EBELN.

ENDSELECT.

IF SY-SUBRC NE 0.

CLEAR SSCRFIELDS-UCOMM.

MESSAGE E717(M8).

ENDIF. " IF SY-SUBRC NE 0

ENDIF. " IF NOT S_EBELN[]...

ENDFORM. " VALIDATE_PD_NUM

&----


*& Form VALIDATE_VEN_NUM

&----


  • Subroutine to validate Vendor Number

----


  • There are no interface parameters to be passed to this subroutine.

----


FORM VALIDATE_VEN_NUM .

IF NOT S_LIFNR[] IS INITIAL.

SELECT LIFNR " Vendor Number

FROM LFA1

INTO W_LIFNR

UP TO 1 ROWS

WHERE LIFNR IN S_LIFNR.

ENDSELECT.

IF SY-SUBRC NE 0.

CLEAR SSCRFIELDS-UCOMM.

MESSAGE E002(M8) WITH W_SPACE.

ENDIF. " IF SY-SUBRC NE 0

ENDIF. " IF NOT S_LIFNR[]...

ENDFORM. " VALIDATE_VEN_NUM

&----


*& Form VALIDATE_PUR_GRP

&----


  • Subroutine to validate the Purchase Group

----


  • There are no interface parameters to be passed to this subroutine.

----


FORM VALIDATE_PUR_GRP .

IF NOT S_EKGRP[] IS INITIAL.

SELECT EKGRP " Purchase Group

FROM T024

INTO W_EKGRP

UP TO 1 ROWS

WHERE EKGRP IN S_EKGRP.

ENDSELECT.

IF SY-SUBRC NE 0.

CLEAR SSCRFIELDS-UCOMM.

MESSAGE E622(M8) WITH W_SPACE.

ENDIF. " IF SY-SUBRC NE 0

ENDIF. " IF NOT S_EKFRP[]...

ENDFORM. " VALIDATE_PUR_GRP

This code is for Validating Purchase Orders and Purchasing Group...

Develop your own code by referring this sample code.

Regards,

Pavan.

Read only

former_member196280
Active Contributor
0 Likes
530

Do your validation in

<b>at selection-screen.</b>

Ex:,

at selection-screen.

select single * from mara into <internal table name>

where matnr = <parameter name> and matkl = <parameter name> .

IF if sy-subrc NE 0.

      • Erorr message

ENDIF..

Reward points to all useful efforts.

Regards,

SaiRam