Skip to Content
0
Former Member
Sep 10, 2007 at 01:49 PM

bdc validations

17 Views

can any one write the validations for the bdc recording code that must show error message if if ur entring the wrong values in particular field.

&----


*& Report ZTESTIN *

*& *

&----


*& *

*& *

&----


REPORT ZTESTIN.

TABLES :LFA1,LFB1,LFM1.

PARAMETERS : P_FILE LIKE RLGRAP-FILENAME.

*DATA :V_FILE LIKE RLGRAP-FILENAME.

DATA : BEGIN OF IT_VEND OCCURS 0,

BUKRS TYPE LFB1-BUKRS,

EKORG TYPE LFM1-EKORG,

KTOKK TYPE LFA1-KTOKK,

NAME1 TYPE LFA1-NAME1,

SORTL TYPE LFA1-SORTL,

LAND1 TYPE LFA1-LAND1,

AKONT TYPE LFB1-AKONT,

FDGRV TYPE LFB1-FDGRV,

WAERS TYPE LFM1-WAERS,

END OF IT_VEND.

.

  • Call Function 'F4_FILENAME'

  • Exporting

  • Program_Name = SYST-CPROG9986772991

  • DYNPRO_NUMBER = SYST-DYNNR

  • FIELD_NAME = ''

  • IMPORTING

  • FILE_NAME = P_File.

  • ENDIF.

DATA :BEGIN OF G_BDCDATA OCCURS 0.

INCLUDE STRUCTURE BDCDATA.

DATA : END OF G_BDCDATA.

DATA:FILE TYPE STRING .

At Selection-Screen On Value-Request For P_File.

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

EXPORTING

PROGRAM_NAME = SYST-REPID

DYNPRO_NUMBER = SYST-DYNNR

  • FIELD_NAME = ' '

  • STATIC = ' '

  • MASK = ' '

CHANGING

FILE_NAME = P_FILE

  • EXCEPTIONS

  • MASK_TOO_LONG = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

start-of-selection.

FILE = p_file.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = FILE

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = IT_VEND

  • EXCEPTIONS

  • FILE_OPEN_ERROR = 1

  • FILE_READ_ERROR = 2

  • NO_BATCH = 3

  • GUI_REFUSE_FILETRANSFER = 4

  • INVALID_TYPE = 5

  • NO_AUTHORITY = 6

  • UNKNOWN_ERROR = 7

  • BAD_DATA_FORMAT = 8

  • HEADER_NOT_ALLOWED = 9

  • SEPARATOR_NOT_ALLOWED =

  • HEADER_TOO_LONG = 11

  • UNKNOWN_DP_ERROR = 12

  • ACCESS_DENIED = 13

  • DP_OUT_OF_MEMORY = 14

  • DISK_FULL = 15

  • DP_TIMEOUT = 16

  • OTHERS = 17

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

end-of-selection.

perform bdc_vendor.

&----


*& Form bdc_vendor

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM bdc_vendor .

*perform open_group.

  • first screen

LOOP AT IT_VEND.

perform bdc_dynpro using 'SAPMF02K' '0100'.

perform bdc_field using 'BDC_CURSOR'

'RF02K-KTOKK'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RF02K-BUKRS'

IT_VEND-BUKRS.

perform bdc_field using 'RF02K-EKORG'

IT_VEND-EKORG.

perform bdc_field using 'RF02K-KTOKK'

IT_VEND-KTOKK.

  • personal info screen 0110

perform bdc_dynpro using 'SAPMF02K' '0110'.

perform bdc_field using 'BDC_CURSOR'

'LFA1-LAND1'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'LFA1-NAME1'

IT_VEND-NAME1.

perform bdc_field using 'LFA1-SORTL'

IT_VEND-SORTL.

perform bdc_field using 'LFA1-LAND1'

IT_VEND-LAND1.

perform bdc_dynpro using 'SAPMF02K' '0120'.

perform bdc_field using 'BDC_CURSOR'

'LFA1-KUNNR'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_dynpro using 'SAPMF02K' '0130'.

perform bdc_field using 'BDC_CURSOR'

'LFBK-BANKS(01)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_dynpro using 'SAPMF02K' '0210'.

perform bdc_field using 'BDC_CURSOR'

'LFB1-FDGRV'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'LFB1-AKONT' " Reference acc

IT_VEND-AKONT.

perform bdc_field using 'LFB1-FDGRV'

IT_VEND-FDGRV. "cash mgt group

perform bdc_dynpro using 'SAPMF02K' '0215'.

perform bdc_field using 'BDC_CURSOR'

'LFB1-ZTERM'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_dynpro using 'SAPMF02K' '0220'.

perform bdc_field using 'BDC_CURSOR'

'LFB5-MAHNA'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

  • currency screen

perform bdc_dynpro using 'SAPMF02K' '0310'.

perform bdc_field using 'BDC_CURSOR'

'LFM1-WAERS'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'LFM1-WAERS'

IT_VEND-WAERS. "currency

perform bdc_dynpro using 'SAPMF02K' '0320'.

perform bdc_field using 'BDC_CURSOR'

'RF02K-LIFNR'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

*CALL TRANSACTION 'XK01' USING G_BDCDATA MODE 'A'.

perform bdc_dynpro using 'SAPLSPO1' '0300'.

perform bdc_field using 'BDC_OKCODE'

'=YES'.

*perform bdc_transaction using 'XK01'.

CALL TRANSACTION 'XK01' USING G_BDCDATA MODE 'A' .

ENDLOOP.

*perform close_group.

ENDFORM. " bdc_vendor

&----


*& Form bdc_dynpro

&----


  • text

----


  • -->P_0124 text

  • -->P_0125 text

----


FORM bdc_dynpro USING p_progname

p_screenno.

  • p_progname =

G_BDCDATA-PROGRAM = P_PROGNAME.

G_BDCDATA-DYNPRO = P_SCREENNO.

G_BDCDATA-DYNBEGIN = 'X'.

APPEND G_BDCDATA.

CLEAR G_BDCDATA.

ENDFORM. " bdc_dynpro

&----


*& Form bdc_field

&----


  • text

----


  • -->P_0274 text

  • -->P_0275 text

----


FORM bdc_field USING P_FNAM

P_FVAL.

G_BDCDATA-FNAM = P_FNAM.

G_BDCDATA-FVAL = P_FVAL.

APPEND G_BDCDATA.

CLEAR G_BDCDATA.

ENDFORM. " bdc_field