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: 

BDC Stops and if press F8 continues normally.

Former Member
0 Kudos
610

Hi all,

iam created a BDC to upload multiple Item lines under one Header line item,

the problem is after the first Item line it stops and if we press F8 it goes to Next Item Line.

and executes normally,

But BDC is executed in background mode only but even it ask the user input F8 in between .

my flat file will look like this

10-----ACC


test--


header line -


-110--


Item line 1--


-120--


Item line 2--


-130--


Item line 3--


Points will be rewarded.

Regards,

Ravi

4 REPLIES 4

manubhutani
Active Contributor
0 Kudos
336

did'nt get ur ques..

former_member186099
Contributor
0 Kudos
336

Hi,

Check whether you have mentioned the events properly in ur code or not.

There should be START OF SELECTION just after the data declaration and the screen declarations.

Thanks,

Prasanna

Former Member
0 Kudos
336

Hi Ravi,

I am sending on sample program to upload the purchase order with item details.

report ZGPO no standard page heading line-size 255.

*%%%%%%%%%########$$$$$$$$$$$$$$$$$$$$$$$$$_______FLAT FILE

*H 1000 nb 26.12.2004 1000 001

*I 100-100 35 92 1000 0001

*I 100-110 35 90 1000 0001

*I 100-120 35 95 1000 0001

*H 1000 nb 28.12.2004 1000 001

*I 100-100 35 92 1000 0001

*I 100-110 35 90 1000 0001

*I 100-120 35 95 1000 0001

*H 1000 nb 29.12.2004 1000 001

*I 100-100 35 92 1000 0001

*I 100-110 35 90 1000 0001

*I 100-120 35 95 1000 0001

*H 1000 nb 29.12.2004 1000 001

*I 100-100 35 92 1000 0001

*I 100-110 35 90 1000 0001

*I 100-120 35 95 1000 0001

*H 1000 nb 31.12.2004 1000 001

*I 100-100 35 92 1000 0001

*I 100-110 35 90 1000 0001

*I 100-120 35 95 1000 0001

*H 1000 nb 01.01.2005 1000 001

*I 100-100 35 92 1000 0001

*I 100-110 35 90 1000 0001

*I 100-120 35 95 1000 0001

*H 1000 nb 02.02.2006 1000 001

*I 100-100 35 92 1000 0001

*I 100-110 35 90 1000 0001

*I 100-120 35 95 1000 0001

TABLES: T024E,

T024,

T001W,

T001L,

LFA1,

LFM1,

MARA,

MARC,

T100.

*CONSTANTS

*VARIABLES

DATA:V_LIFNR LIKE LFA1-LIFNR,

V_BSART LIKE EKKO-BSART,

V_BEDAT LIKE EKKO-BEDAT,

V_BEDAT1(10),

V_EKORG LIKE EKKO-EKORG,

V_EKGRP LIKE EKKO-EKGRP,

V_NETPR(14),

V_H_ERROR,

V_I_ERROR,

V_I_CORRECT,

V_ERROR_LEVEL(5),

N TYPE I VALUE 0,

M TYPE I VALUE 0,

V_PATH(128),

L_MSTRING(480),

GUIFILE TYPE STRING.

*INTERNAL TABLES

*INTERNAL TABLE FOR UPLOADING DATA FROM FLAT FILE

DATA:BEGIN OF I_INPUT OCCURS 0,

X TYPE STRING,

V1(10),

V2 TYPE STRING,

V3 TYPE STRING,

V4 TYPE STRING,

V5 TYPE STRING,

END OF I_INPUT.

*INTERNAL TABLE TO COPY DATA FROM I_INPUT ACCORDING TO OUR REQUIRED

*FORMAT

DATA:begin of I_ME21 occurs 0,

LIFNR LIKE LFA1-LIFNR,

BSART LIKE EKKO-BSART,

BEDAT(10),

EKORG LIKE EKKO-EKORG,

EKGRP LIKE EKKO-EKGRP,

EMATN LIKE EKPO-EMATN,

MENGE(17),

NETPR(14),

WERKS LIKE EKPO-WERKS,

LGORT LIKE EKPO-LGORT,

END OF I_ME21.

*INTERNAL TABLE TO HOLD RECORS THAT PASS THROUGH VALIDATION

DATA:BEGIN OF I_ME21_PTV OCCURS 0,

LIFNR LIKE LFA1-LIFNR,

BSART LIKE EKKO-BSART,

BEDAT(10),

EKORG LIKE EKKO-EKORG,

EKGRP LIKE EKKO-EKGRP,

EMATN LIKE EKPO-EMATN,

MENGE(17),

NETPR(14),

WERKS LIKE EKPO-WERKS,

LGORT LIKE EKPO-LGORT,

END OF I_ME21_PTV.

*INTERNAL TABLE TO HOLD RECORS THAT FAIL THROUGH VALIDATION

DATA:BEGIN OF I_ME21_FTV OCCURS 0,

LIFNR LIKE LFA1-LIFNR,

BSART LIKE EKKO-BSART,

BEDAT(10), " LIKE EKKO-BEDAT,

EKORG LIKE EKKO-EKORG,

EKGRP LIKE EKKO-EKGRP,

EMATN LIKE EKPO-EMATN,

MENGE(17), " LIKE EKPO-MENGE,

NETPR(14),

WERKS LIKE EKPO-WERKS,

LGORT LIKE EKPO-LGORT,

ERR_MSG(255),

END OF I_ME21_FTV.

*INTERNAL TABLE TO HANDLE ERRORS FOR CALL TRANSACTION METHOD

DATA:I_ERROR like I_ME21_FTV OCCURS 0 WITH HEADER LINE,

I_ME21_IM LIKE I_ME21 OCCURS 0 WITH HEADER LINE.

DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

*TEXT-001 = SELECT ANY RADIOBUTTON

PARAMETER : R1 RADIOBUTTON GROUP G1,

*SELECT R1 FOR PRESENTATION SERVER FILE PATH AND PRESS ENTER

R2 RADIOBUTTON GROUP G1.

*SELECT R2 FOR APPLICATION SERVER FILE PATH AND PRESS ENTER

SELECTION-SCREEN : END OF BLOCK B1 .

SELECTION-SCREEN : BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.

*TEXT-002 = FILEPATH

PARAMETER :P_PATH LIKE RLGRAP-FILENAME MODIF ID ABC,

  • "P_PATH = PRESENTATION SERVER FILE PATH

A_PATH(128) MODIF ID BCA. "APPLICATION SERVER FILE PATH

SELECTION-SCREEN : END OF BLOCK B2.

SELECTION-SCREEN : BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-003.

*TEXT-003 = SESSION PARAMETERS DETAILS

PARAMETERS :SESSION(12),

HOLDDATE LIKE SY-DATUM.

SELECTION-SCREEN : END OF BLOCK B3.

*SELECTION-SCREEN : BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-003.

*

*PARAMETERS :CTUMODE LIKE CTU_PARAMS-DISMODE DEFAULT 'N',

  • "A: show all dynpros

  • "E: show dynpro on error only

  • "N: do not display dynpro

  • CUPDATE LIKE CTU_PARAMS-UPDMODE DEFAULT 'S'.

*"S: synchronously

*"A: asynchronously

*"L: local

*SELECTION-SCREEN : END OF BLOCK B3.

AT SELECTION-SCREEN OUTPUT.

LOOP AT SCREEN.

IF R1 EQ 'X'.

*"R1 = RADIO BUTTON TO ACTIVATE P_PATH

IF SCREEN-GROUP1 EQ 'BCA'.

SCREEN-INPUT = 0.

ENDIF.

*"R2 = RADIO BUTTON TO ACTIVATE A_PATH

ELSEIF R2 EQ 'X'. "R3 = RADIO

IF SCREEN-GROUP1 EQ 'ABC'.

SCREEN-INPUT = 0.

ENDIF.

ENDIF.

MODIFY SCREEN.

ENDLOOP.

*VALUE REQUEST PATH OF THE FILE ON PRESENTATION SERVER.

AT selection-SCREEN ON VALUE-REQUEST FOR P_PATH.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

  • DYNPRO_NUMBER = SYST-DYNNR

  • FIELD_NAME = ' '

IMPORTING

FILE_NAME = V_PATH.

IF NOT V_PATH IS INITIAL.

P_PATH = V_PATH.

ENDIF.

AT SELECTION-SCREEN ON SESSION.

IF SESSION IS INITIAL.

MESSAGE E010(ZMSG) WITH 'ENTER NAME OF THE SESSION'.

ENDIF.

AT SELECTION-SCREEN ON P_PATH.

IF P_PATH IS INITIAL.

MESSAGE E011(ZMSG) WITH 'ENTER NAME OF THE PATH'.

ENDIF.

*AT SELECTION-SCREEN ON A_PATH.

*

  • IF P_PATH IS INITIAL.

  • MESSAGE E011(ZMSG) WITH 'ENTER NAME OF THE PATH'.

  • ENDIF.

start-of-selection.

IF R1 EQ 'X'.

GUIFILE = P_PATH.

*UPLOADING THE DATA INTO THE INTERNAL TABLE

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = GUIFILE

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = I_INPUT

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 = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

OTHERS = 17.

ELSEIF R2 EQ 'X'.

IF NOT A_PATH IS INITIAL.

OPEN DATASET A_PATH FOR APPENDING IN BINARY MODE .

IF SY-SUBRC EQ 0.

WRITE:/ 'FILE OPENED',sy-sysid.

ENDIF.

ENDIF.

DO .

READ DATASET A_PATH INTO I_ME21.

IF SY-SUBRC EQ 0.

APPEND I_ME21.

CLEAR I_ME21.

else .

exit.

ENDIF.

ENDDO.

CLOSE DATASET A_PATH.

ENDIF.

*TRANFER THE DATA FROM I_INPUT TO I_ME21 TO GET REQUIRED FORMAT

LOOP AT I_INPUT.

IF I_INPUT-X = 'H'.

I_ME21-LIFNR = I_INPUT-V1.

I_ME21-BSART = I_INPUT-V2.

I_ME21-BEDAT = I_INPUT-V3.

I_ME21-EKORG = I_INPUT-V4.

I_ME21-EKGRP = I_INPUT-V5.

APPEND I_ME21.

CLEAR I_ME21.

ELSE.

I_ME21-EMATN = I_INPUT-V1.

I_ME21-MENGE = I_INPUT-V2.

I_ME21-NETPR = I_INPUT-V3.

I_ME21-WERKS = I_INPUT-V4.

I_ME21-LGORT = I_INPUT-V5.

APPEND I_ME21.

CLEAR I_ME21.

ENDIF.

ENDLOOP.

PERFORM OPEN_GROUP USING SESSION HOLDDATE.

LOOP AT I_ME21_PTV.

IF NOT I_ME21_PTV-LIFNR IS INITIAL.

IF NOT SY-TABIX EQ 1.

perform save.

ENDIF.

perform scr_100.

ELSE.

N = N + 1.

IF N = 1.

perform scr_120_01.

ELSEIF N GE 2.

perform scr_120_02.

ENDIF.

ENDIF.

ENDLOOP.

perform save.

PERFORM CLOSE_GROUP.

&----


*& Form OPEN_GROUP

&----


  • text

----


  • -->P_SESSIONID text

  • -->P_HOLDDATE text

----


FORM OPEN_GROUP USING P_SESSIONID

P_HOLDDATE.

  • open batchinput group

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING CLIENT = SY-MANDT

GROUP = P_SESSIONID

USER = SY-UNAME

KEEP = 'X'

HOLDDATE = P_HOLDDATE.

WRITE: /(30) 'BDC_OPEN_GROUP'(I02),

(12) 'returncode:'(I05),

SY-SUBRC.

ENDFORM. " OPEN_GROUP

&----


*& Form CLOSE_GROUP

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM CLOSE_GROUP .

CALL FUNCTION 'BDC_CLOSE_GROUP'.

WRITE: /(30) 'BDC_CLOSE_GROUP'(I04),

(12) 'returncode:'(I05),

SY-SUBRC.

.

ENDFORM. " CLOSE_GROUP

*&----


*

*& Form scr_100

*&----


*

  • text

*----


*

  • --> p1 text

  • <-- p2 text

*----


*

FORM scr_100 .

perform bdc_dynpro using 'SAPMM06E' '0100'.

perform bdc_field using 'BDC_CURSOR'

'EKKO-EKGRP'.

perform bdc_field using 'BDC_OKCODE'

'=AB'.

perform bdc_field using 'EKKO-LIFNR'

I_ME21_PTV-LIFNR. "'1000'.

perform bdc_field using 'RM06E-BSART'

I_ME21_PTV-BSART."'nb'.

perform bdc_field using 'RM06E-BEDAT'

I_ME21_PTV-BEDAT."'31.05.2007'.

perform bdc_field using 'EKKO-EKORG'

I_ME21_PTV-EKORG. "'1000'.

perform bdc_field using 'EKKO-EKGRP'

I_ME21_PTV-EKGRP. "'001'.

I_ME21_IM = I_ME21_PTV.

APPEND I_ME21_IM.

CLEAR I_ME21_IM.

ENDFORM. " scr_100

*&----


*

*& Form scr_120_01

*&----


*

  • text

*----


*

  • --> p1 text

  • <-- p2 text

*----


*

FORM scr_120_01 .

perform bdc_dynpro using 'SAPMM06E' '0120'.

perform bdc_field using 'BDC_CURSOR'

'EKPO-LGORT(01)'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'EKPO-EMATN(01)'

I_ME21_PTV-EMATN.

perform bdc_field using 'EKPO-MENGE(01)'

I_ME21_PTV-MENGE.

perform bdc_field using 'EKPO-NETPR(01)'

I_ME21_PTV-NETPR.

perform bdc_field using 'EKPO-WERKS(01)'

I_ME21_PTV-WERKS.

perform bdc_field using 'EKPO-LGORT(01)'

I_ME21_PTV-LGORT.

I_ME21_IM = I_ME21_PTV.

APPEND I_ME21_IM.

CLEAR I_ME21_IM.

ENDFORM. " scr_120_01

*&----


*

*& Form scr_120_02

*&----


*

  • text

*----


*

  • --> p1 text

  • <-- p2 text

*----


*

FORM scr_120_02 .

perform bdc_dynpro using 'SAPMM06E' '0120'.

perform bdc_field using 'BDC_CURSOR'

'EKPO-LGORT(02)'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RM06E-EBELP'

'10'.

perform bdc_field using 'EKPO-EMATN(02)'

I_ME21_PTV-EMATN. "100-120'.

perform bdc_field using 'EKPO-MENGE(02)'

I_ME21_PTV-MENGE.

perform bdc_field using 'EKPO-NETPR(02)'

I_ME21_PTV-NETPR.

perform bdc_field using 'EKPO-WERKS(02)'

I_ME21_PTV-WERKS. " '1000'.

perform bdc_field using 'EKPO-LGORT(02)'

I_ME21_PTV-LGORT. "'0001'.

perform bdc_dynpro using 'SAPMM06E' '0120'.

perform bdc_field using 'BDC_CURSOR'

'RM06E-EBELP'.

perform bdc_field using 'BDC_OKCODE'

'=NP'.

perform bdc_field using 'RM06E-EBELP'

'10'.

I_ME21_IM = I_ME21_PTV.

APPEND I_ME21_IM.

CLEAR I_ME21_IM.

ENDFORM. " scr_120_02

*&----


*

*& Form save

*&----


*

  • text

*----


*

  • --> p1 text

  • <-- p2 text

*----


*

FORM save .

DATA:L_MSG(255).

perform bdc_dynpro using 'SAPMM06E' '0120'.

perform bdc_field using 'BDC_CURSOR'

'RM06E-EBELP'.

perform bdc_field using 'BDC_OKCODE'

'=BU'.

PERFORM BDC_TRANSACTION USING 'ME21'.

  • call transaction 'ME21' using BDCDATA

  • MODE CTUMODE

  • UPDATE CUPDATE

  • MESSAGES INTO MESSTAB.

*

  • IF SY-SUBRC EQ 0.

  • CLEAR BDCDATA.

  • REFRESH BDCDATA.

  • M = M + 1. "CALCULATION FOR TOTAL NO.OF RECORDS CREATED.

*

  • ELSE.

**ERROR HANDLING IN CALL TRANSACTION.

  • CLEAR BDCDATA.

  • REFRESH BDCDATA.

  • CALL FUNCTION 'FORMAT_MESSAGE'

  • EXPORTING

  • ID = SY-MSGID

  • LANG = '-D'

  • NO = SY-MSGNO

  • V1 = SY-MSGV1

  • V2 = SY-MSGV2

  • V3 = SY-MSGV3

  • V4 = SY-MSGV4

  • IMPORTING

  • MSG = L_MSG

  • EXCEPTIONS

  • NOT_FOUND = 1

  • OTHERS = 2.

  • IF SY-SUBRC EQ 0.

*

  • LOOP AT I_ME21_IM.

*

  • I_ERROR-LIFNR = I_ME21_IM-LIFNR.

  • I_ERROR-BEDAT = I_ME21_IM-BEDAT.

  • I_ERROR-BSART = I_ME21_IM-BSART.

  • I_ERROR-EKORG = I_ME21_IM-EKORG.

  • I_ERROR-EKGRP = I_ME21_IM-EKGRP.

*

  • I_ERROR-EMATN = I_ME21_IM-EMATN.

  • I_ERROR-MENGE = I_ME21_IM-MENGE.

  • I_ERROR-WERKS = I_ME21_IM-WERKS.

  • I_ERROR-LGORT = I_ME21_IM-LGORT.

  • I_ERROR-ERR_MSG = L_MSG.

*

  • APPEND I_ERROR.

  • CLEAR I_ERROR.

  • ENDLOOP.

  • REFRESH I_ME21_IM.

  • ENDIF.

  • ENDIF.

ENDFORM. " save

0 Kudos
336

Hi,

After reading the first line it stops because it needs F8 (Enter) or ok_code = Enter (just capture event for Enter and use it).

This event just include after reading of first line. This should solve your issue.

Please reward if useful.

Regards,

Ramesh