Application Development 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: 

Doubt in writing a report from specifications

Former Member
0 Kudos
86

Hi,

1.On a selection-screen with four select -options as s_vbeln,s_vkorg,s_vtweg,s_spart. I need to validate and write a error message ' enter atleast one field' if it is executed without any values.

2.Also validation should be done that the entered value is correct or incorrect and if it is incorrect it should show the error message concerned to the fields for example if the vkorg value is entered incorrect , it should display'' please enter valid entry' respectively to all the fields.

Can anyone send me a code on how to perform this.

Thanks,

Stalin.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
55

hi.

i'm sending u the code check it and understand it for ur own fields, select ur own fields from there master tables for single validation and check for each field , and for combine validation for wrong combination of data eneterd on selection screen or no data entered , check this sample code::

**********************VALIDATON OF SONUMBER************************

SELECT SINGLE vbeln INTO (wa_orderhead-vbeln)

FROM vbuk

CLIENT SPECIFIED

WHERE mandt = sy-mandt

AND vbeln IN s_vbeln.

IF sy-subrc <> 0.

MESSAGE e001. "so number does not exist

ENDIF.

**********************VALIDATON OF SOTYPE************************

SELECT SINGLE auart INTO (wa_orderhead-auart)

FROM tvak

WHERE auart = s_auart.

IF sy-subrc <> 0.

MESSAGE e002. "doc. type does not exist

ENDIF.

**********************VALIDATON OF SOLD TO PARTY**********************

SELECT SINGLE kunnr INTO (wa_orderhead-kunnr)

FROM kna1

WHERE kunnr = s_kunnr.

IF sy-subrc <> 0.

MESSAGE e003. "customer does not exist

ENDIF.

**********************VALIDATON OF BLOCK************************

SELECT SINGLE lifsp INTO (wa_orderhead-lifsp)

FROM tvls

WHERE lifsp = s_lifsk.

IF sy-subrc <> 0.

MESSAGE e004.

ENDIF.

**********************VALIDATON OF ORGANISTION************************

SELECT SINGLE vkorg INTO (wa_orderhead-vkorg)

FROM tvko

WHERE vkorg = s_vkorg.

IF sy-subrc <> 0.

MESSAGE e005.

ENDIF.

**********************VALIDATON OF DISTRIBUTION***********************

SELECT SINGLE vtweg INTO (wa_orderhead-vtweg)

FROM tvkov

WHERE vkorg = s_vkorg and

vtweg = s_vtweg.

IF sy-subrc <> 0.

MESSAGE e006.

ENDIF.

**********************VALIDATON OF DIVISION************************

SELECT SINGLE spart INTO (wa_orderhead-spart)

FROM tvta

WHERE vkorg = s_vkorg and

vtweg = s_vtweg and

spart = s_spart.

IF sy-subrc <> 0.

MESSAGE e007.

ENDIF.

*************************VALIDATION OF DATE************************

IF s_erdat-low > sy-datum OR s_erdat > sy-datum.

MESSAGE e008.

ENDIF.

*********************COMBINATION VALIDATION*********************

SELECT SINGLE vbeln

auart

vbtyp

erdat

ernam

lifsk

vkorg

vtweg

spart

kunnr

waerk

vsbed INTO CORRESPONDING FIELDS OF wa_orderhead

FROM vbak

WHERE vbeln = s_vbeln AND

auart = s_auart AND

vbtyp = s_vbtyp AND

erdat = s_erdat AND

ernam = s_ernam AND

kunnr = s_kunnr AND

lifsk = s_lifsk AND

vkorg = s_vkorg AND

vtweg = s_vtweg AND

spart = s_spart .

IF sy-subrc <> 0.

MESSAGE e009.

ENDIF.

SELECT SINGLE vbeln

lfgsk

lfstk

fkstk INTO (wa_orderhead-vbeln,wa_orderhead-lfgsk,

wa_orderhead-lfstk,wa_orderhead-fkstk)

FROM vbuk

WHERE vbeln = s_vbeln AND

lfgsk = s_lfgsk AND

lfstk = s_lfstk AND

fkstk = s_fkstk.

IF sy-subrc <> 0.

MESSAGE e009.

ENDIF.

ENDFORM. " validate_data

thanks and

reward points if helpful please.

Edited by: Abhishek Ojha on Feb 6, 2008 6:22 AM

3 REPLIES 3

Former Member
0 Kudos
55

This is a dupliczte post. Please see my answers in the other one.

Rob

Former Member
0 Kudos
56

hi.

i'm sending u the code check it and understand it for ur own fields, select ur own fields from there master tables for single validation and check for each field , and for combine validation for wrong combination of data eneterd on selection screen or no data entered , check this sample code::

**********************VALIDATON OF SONUMBER************************

SELECT SINGLE vbeln INTO (wa_orderhead-vbeln)

FROM vbuk

CLIENT SPECIFIED

WHERE mandt = sy-mandt

AND vbeln IN s_vbeln.

IF sy-subrc <> 0.

MESSAGE e001. "so number does not exist

ENDIF.

**********************VALIDATON OF SOTYPE************************

SELECT SINGLE auart INTO (wa_orderhead-auart)

FROM tvak

WHERE auart = s_auart.

IF sy-subrc <> 0.

MESSAGE e002. "doc. type does not exist

ENDIF.

**********************VALIDATON OF SOLD TO PARTY**********************

SELECT SINGLE kunnr INTO (wa_orderhead-kunnr)

FROM kna1

WHERE kunnr = s_kunnr.

IF sy-subrc <> 0.

MESSAGE e003. "customer does not exist

ENDIF.

**********************VALIDATON OF BLOCK************************

SELECT SINGLE lifsp INTO (wa_orderhead-lifsp)

FROM tvls

WHERE lifsp = s_lifsk.

IF sy-subrc <> 0.

MESSAGE e004.

ENDIF.

**********************VALIDATON OF ORGANISTION************************

SELECT SINGLE vkorg INTO (wa_orderhead-vkorg)

FROM tvko

WHERE vkorg = s_vkorg.

IF sy-subrc <> 0.

MESSAGE e005.

ENDIF.

**********************VALIDATON OF DISTRIBUTION***********************

SELECT SINGLE vtweg INTO (wa_orderhead-vtweg)

FROM tvkov

WHERE vkorg = s_vkorg and

vtweg = s_vtweg.

IF sy-subrc <> 0.

MESSAGE e006.

ENDIF.

**********************VALIDATON OF DIVISION************************

SELECT SINGLE spart INTO (wa_orderhead-spart)

FROM tvta

WHERE vkorg = s_vkorg and

vtweg = s_vtweg and

spart = s_spart.

IF sy-subrc <> 0.

MESSAGE e007.

ENDIF.

*************************VALIDATION OF DATE************************

IF s_erdat-low > sy-datum OR s_erdat > sy-datum.

MESSAGE e008.

ENDIF.

*********************COMBINATION VALIDATION*********************

SELECT SINGLE vbeln

auart

vbtyp

erdat

ernam

lifsk

vkorg

vtweg

spart

kunnr

waerk

vsbed INTO CORRESPONDING FIELDS OF wa_orderhead

FROM vbak

WHERE vbeln = s_vbeln AND

auart = s_auart AND

vbtyp = s_vbtyp AND

erdat = s_erdat AND

ernam = s_ernam AND

kunnr = s_kunnr AND

lifsk = s_lifsk AND

vkorg = s_vkorg AND

vtweg = s_vtweg AND

spart = s_spart .

IF sy-subrc <> 0.

MESSAGE e009.

ENDIF.

SELECT SINGLE vbeln

lfgsk

lfstk

fkstk INTO (wa_orderhead-vbeln,wa_orderhead-lfgsk,

wa_orderhead-lfstk,wa_orderhead-fkstk)

FROM vbuk

WHERE vbeln = s_vbeln AND

lfgsk = s_lfgsk AND

lfstk = s_lfstk AND

fkstk = s_fkstk.

IF sy-subrc <> 0.

MESSAGE e009.

ENDIF.

ENDFORM. " validate_data

thanks and

reward points if helpful please.

Edited by: Abhishek Ojha on Feb 6, 2008 6:22 AM

0 Kudos
55

Hi Abhishek,

Thanks for ur reply...it was a good replyand i appreciate it.

I have added points for you..check your score..will keep in touch for future scoring ok.

Stalin.