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

bdc using call transaction

Former Member
0 Likes
612

please tell me why my program is not getting executed after giving file name.

report Z_PP_BDC1

no standard page heading line-size 255.

*REQUEST NO.:DEVK903710

************************************************************************

*& Table Declaration

************************************************************************

TABLES : IBIPPARMS.

************************************************************************

*& Types

************************************************************************

TYPES : BEGIN OF TY_ITAB,

MATNR TYPE MATNR, "MATERIAL NO

WERKS TYPE WERKS, "PLANT

STLAN TYPE STLAN, "BOM USAGE

DATUV TYPE DATUV, "VALID DATE

BMENG TYPE BMENG, "BASE QUANTITY

IDNRK TYPE IDNRK, "COMPONENT

MENGE TYPE RC29P-MENGE, "QUANTITY

MEINS TYPE MEINS, "UNIT

POSTP TYPE POSTP, "ITEM CATEGORY

END OF TY_ITAB.

***********************************************************************

*& DATA Declaration

***********************************************************************

DATA : IT_ITAB TYPE TABLE OF TY_ITAB WITH HEADER LINE.

DATA : IT_BDCDATA TYPE TABLE OF BDCDATA WITH HEADER LINE.

DATA : IT_BDCMSGCOLL TYPE TABLE OF BDCMSGCOLL WITH HEADER LINE.

DATA : P_FILE1 TYPE STRING ,"FILE NAME

V_LINES TYPE I.

DATA : IT1_ITAB like IT_ITAB occurs 0 with header line.

************************************************************************

*& SELECTION-SCREEN DECLARATION

************************************************************************

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

PARAMETERS : P_FILE TYPE LOCALFILE OBLIGATORY."FILE NAME

SELECTION-SCREEN END OF BLOCK B1 .

************************************************************************

  • AT-SELECTION-SCREEN DECALRATION *

  • *

************************************************************************

----


AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

----


clear : P_FILE.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

DYNPRO_NUMBER = SYST-DYNNR

IMPORTING

FILE_NAME = P_FILE.

IF P_FILE IS NOT INITIAL.

  • VALIDATE FILE TYPE

PERFORM SUB_VALIDATE_txt_TYPE.

ENDIF.

************************************************************************

  • START-OF-SELECTION

************************************************************************

start-of-selection.

perform upload.

perform bdc.

&----


*& Form upload

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM upload .

clear : P_FILE1.

P_FILE1 = P_FILE.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = P_FILE1

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

TABLES

DATA_TAB = IT_ITAB

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.

IF SY-SUBRC <> 0.

endif.

ENDFORM. " upload

form bdc.

*COPY DATA FROM IT_ITAB INTO IT_ITAB1

****************************************************

IT1_ITAB[] = IT_ITAB[].

*IF SY-SUBRC <> 0 OR IT_ITAB IS INITIAL.

    • UNABLE TO UPLOAD DATA FROM FLAT FILE

*MESSAGE I003(ZMSG).

*ENDIF.

&----


*& Form bdc

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


*FORM BDC.

LOOP AT IT_ITAB.

REFRESH IT_BDCDATA .

*FIRST SCREEN

perform bdc_dynpro using 'SAPLCSDI' '0100'.

perform bdc_field using 'BDC_CURSOR'

'RC29N-DATUV'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RC29N-MATNR'

IT_ITAB-MATNR.

perform bdc_field using 'RC29N-WERKS'

IT_ITAB-WERKS.

perform bdc_field using 'RC29N-STLAN'

IT_ITAB-STLAN.

perform bdc_field using 'RC29N-DATUV'

IT_ITAB-DATUV.

*SECOND SCREEN

perform bdc_dynpro using 'SAPLCSDI' '0110'.

perform bdc_field using 'BDC_CURSOR'

'RC29K-BMENG'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RC29K-BMENG'

IT_ITAB-BMENG.

perform bdc_field using 'RC29K-STLST'

'1'.

*THIRD SCREEN

LOOP AT IT1_ITAB WHERE MATNR = IT_ITAB-MATNR.

perform bdc_dynpro using 'SAPLCSDI' '0111'.

perform bdc_field using 'BDC_CURSOR'

'RC29K-LABOR'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_dynpro using 'SAPLCSDI' '0140'.

perform bdc_field using 'BDC_CURSOR'

'RC29P-POSTP(02)'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

*perform bdc_field using 'RC29P-IDNRK(01)'

  • IT_ITAB-IDNRK.

perform bdc_field using 'RC29P-IDNRK(SY-TABIX)'

IT_ITAB-IDNRK.

perform bdc_field using 'RC29P-IDNRK(02)'

'100017'.

perform bdc_field using 'RC29P-MENGE(SY-TABIX)'

IT_ITAB-MENGE.

perform bdc_field using 'RC29P-MENGE(02)'

'200'.

perform bdc_field using 'RC29P-MEINS(SY-TABIX)'

IT_ITAB-MEINS.

perform bdc_field using 'RC29P-MEINS(02)'

'kg'.

perform bdc_field using 'RC29P-POSTP(SY-TABIX)'

IT_ITAB-POSTP.

perform bdc_field using 'RC29P-POSTP(02)'

'l'.

ENDLOOP.

perform bdc_dynpro using 'SAPLCSDI' '0130'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BDC_CURSOR'

'RC29P-POSNR'.

perform bdc_field using 'RC29P-POSNR'

'0010'.

perform bdc_field using 'RC29P-IDNRK'

'100012'.

perform bdc_field using 'RC29P-MENGE'

'150'.

perform bdc_field using 'RC29P-MEINS'

'KG'.

perform bdc_dynpro using 'SAPLCSDI' '0131'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BDC_CURSOR'

'RC29P-POTX1'.

perform bdc_field using 'RC29P-SANKA'

'X'.

perform bdc_dynpro using 'SAPLCSDI' '0130'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BDC_CURSOR'

'RC29P-POSNR'.

perform bdc_field using 'RC29P-POSNR'

'0020'.

perform bdc_field using 'RC29P-IDNRK'

'100017'.

perform bdc_field using 'RC29P-MENGE'

'200'.

perform bdc_field using 'RC29P-MEINS'

'KG'.

perform bdc_dynpro using 'SAPLCSDI' '0131'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BDC_CURSOR'

'RC29P-POTX1'.

perform bdc_field using 'RC29P-SANKA'

'X'.

perform bdc_dynpro using 'SAPLCSDI' '0140'.

perform bdc_field using 'BDC_CURSOR'

'RC29P-POSNR(01)'.

perform bdc_field using 'BDC_OKCODE'

'=FCBU'.

*perform bdc_transaction using 'CS01'.

*perform close_group.

CALL TRANSACTION 'CS01' USING IT_BDCDATA MODE 'N'

UPDATE 'S'

MESSAGES INTO IT_BDCMSGCOLL.

CLEAR IT_ITAB.

ENDLOOP.

endform.

**GET THE NUMBER OF LINES

*DESCRIBE TABLE IT_BDCMSGCOLL LINES V_LINES.

**ENDFORM.

&----


*& Form SUB_VALIDATE_TXT_TYPE

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM SUB_VALIDATE_txt_TYPE .

DATA : STR1 TYPE LOCALFILE,

STR2 TYPE CHAR3.

SPLIT P_FILE AT '.' INTO STR1 STR2.

TRANSLATE STR2 TO LOWER CASE.

IF STR2 NE 'txt'.

  • please enter '.txt' file format

MESSAGE I001(ZMSG).

LEAVE LIST-PROCESSING.

ENDIF.

ENDFORM. " SUB_VALIDATE_TXT_TYPE

&----


*& Form bdc_dynpro

&----


  • text

----


  • -->P_0160 text

  • -->P_0161 text

----


FORM bdc_dynpro USING PROGRAM DYNPRO.

CLEAR IT_BDCDATA.

IT_BDCDATA-PROGRAM = PROGRAM.

IT_BDCDATA-DYNPRO = DYNPRO.

IT_BDCDATA-DYNBEGIN = 'X'.

APPEND IT_BDCDATA.

ENDFORM. " bdc_dynpro

&----


*& Form bdc_field

&----


  • text

----


  • -->P_0160 text

  • -->P_ENDLOOP text

----


FORM bdc_field USING FNAM FVAL.

CLEAR IT_BDCDATA. .

IT_BDCDATA-FNAM = FNAM.

IT_BDCDATA-FVAL = FVAL.

APPEND IT_BDCDATA.

ENDFORM. " bdc_field

4 REPLIES 4
Read only

Former Member
0 Likes
564

Hi,

Just chck the fields in ur Structure and the field values which you are feeding in to the screen.

You have hard coded most of the field values. Remove all those values and upload data from presentation server and make the mode as 'A', then run it.

Regards,

Suresh

Message was edited by:

SureshKumar Ramamoorthy

Read only

Former Member
0 Likes
564

Hi

You can change the mode to 'A' for call transaction and execute it to see if anything is missing.

Also,

You can debug and see how data is getting populated and how the bdc tab is being populated.

Regards,

Raj

Read only

Former Member
0 Likes
564

hi srinivasa,

I have debugged your program.debug it.keep one break point at "perform upload."if sy-subrc <> 0.check your file format or else

In the internal table your taking only 9 fields but in perform bdc your uploading more than 12 filed's.

your file and internal table should have same number of fields.

just output break point at performs upload and debug the whole program

Read only

Former Member
0 Likes
564

HI srinivas,

can u please post the error what u are getting?

any how u said that ur program is not getting executed after giving file name..

check the file types..coz in fm f4_filename the file type is of rlgrap-filename..

but the filetype in gui_upload wud only be of string(double click the field in se37 and check out the file type)..so u have to convert the file type in f4_filename

to string...

DATA: T_FILE TYPE STRING.

befre start-of-selection....

T_FILE = P_FILE.

and pas t_file in gui_upload fm....pls try and chck out

hope this helps u a bit,

all the best,

regards,

sampath

  • mark helpful answers