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 UPLOAD

Former Member
0 Likes
544

Hi Guru's,

Please modify this report & do justice to D_file,which is nothing but error file to be downloaded.

REPORT ZAS02

NO STANDARD PAGE HEADING "Does not display the standard SAP header

LINE-SIZE 255. "Makes the report width nnn characters

----


  • Tables

----


TABLES : ANLA. "Asset Master Record Segment

----


*

  • Data Declaration

*

----


DATA : BEGIN OF I_ANLA OCCURS 0,

ANLN1 LIKE ANLA-ANLN1, "Main Asset Number

BUKRS LIKE ANLA-BUKRS, "Company Code

TXT50 LIKE ANLA-TXT50, "Asset description

END OF I_ANLA.

DATA : V_FILE TYPE STRING.

----


*

  • Selection-Screen

*

----


SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETERS : UP_FILE LIKE RLGRAP-FILENAME OBLIGATORY.

PARAMETERS : D_FILE LIKE RLGRAP-FILENAME OBLIGATORY.

SELECTION-SCREEN END OF BLOCK b1.

INCLUDE BDCRECX1.

----


*

  • AT Selection-Screen

*

----


AT SELECTION-SCREEN ON VALUE-REQUEST FOR UP_FILE.

PERFORM F4_FILE_DOWNLOAD USING UP_FILE.

START-OF-SELECTION.

PERFORM GET_DATA.

PERFORM UPLOAD_DATA.

&----


*& Form F4_FILE_DOWNLOAD

&----


  • text

----


  • -->P_UP_FILE text

----


FORM F4_FILE_DOWNLOAD USING P_UP_FILE.

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

CHANGING

FILE_NAME = P_UP_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.

ENDFORM. " F4_FILE_DOWNLOAD

&----


&----


*& Form GET_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_DATA .

V_FILE = UP_FILE.

SELECT ANLN1 BUKRS TXT50 FROM ANLA

INTO TABLE I_ANLA.

  • LOOP AT I_ANLA.

  • MOVE-CORRESPONDING I_ANLA TO I_ANLA.

  • APPEND I_ANLA.

  • CLEAR I_ANLA.

  • ENDLOOP.

ENDFORM. " GET_DATA

&----


&----


*& Form UPLOAD_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM UPLOAD_DATA .

V_FILE = UP_FILE.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = V_FILE

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

TABLES

DATA_TAB = I_ANLA

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.

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

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

ENDIF.

ENDFORM. " UPLOAD_DATA

&----


*perform open_group.

LOOP AT I_ANLA.

REFRESH BDCDATA.

CLEAR BDCDATA.

perform bdc_dynpro using 'SAPLAIST' '0100'.

perform bdc_field using 'BDC_CURSOR'

'ANLA-ANLN1'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'ANLA-ANLN1'

'100000'.

perform bdc_field using 'ANLA-ANLN2'

'0'.

perform bdc_field using 'ANLA-BUKRS'

'516'.

perform bdc_dynpro using 'SAPLAIST' '1000'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BDC_CURSOR'

'ANLA-TXT50'.

perform bdc_field using 'ANLA-TXT50'

'Aircondition TEST CC516'.

perform bdc_field using 'ANLA-MENGE'

'1'.

perform bdc_field using 'ANLA-MEINS'

'EA'.

perform bdc_field using 'RA02S-XHIST'

'X'.

perform bdc_field using 'ANLA-AKTIV'

'12/02/2006'.

perform bdc_dynpro using 'SAPLAIST' '1000'.

perform bdc_field using 'BDC_OKCODE'

'=BUCH'.

perform bdc_field using 'BDC_CURSOR'

'ANLA-TXT50'.

perform bdc_field using 'ANLA-TXT50'

'Aircondition TEST CC516'.

perform bdc_field using 'ANLA-MENGE'

'1'.

perform bdc_field using 'ANLA-MEINS'

'EA'.

perform bdc_field using 'RA02S-XHIST'

'X'.

perform bdc_field using 'ANLA-AKTIV'

'12/02/2006'.

perform bdc_transaction using 'AS02'.

ENDLOOP.

*perform close_group.

Please help to up load data .Field “ANLA-TXT50” needs to be changed.

test data like : 152947 100 <b>SUNSUN FIRE 280R</b>

Help me !!!

Thanks & Regards,

Singha

3 REPLIES 3
Read only

Former Member
0 Likes
488

Hi Singha

u r using this one Aircondition TEST CC516 and what has to be changed for this one

Read only

0 Likes
488

hi,

We need to change in code after open_group.

Pls help..

As i've not changed any things on system generated code.

Regards,

Singha

Read only

Former Member
0 Likes
488

hi singha

do the modification in the following lines of the system generated code...

perform bdc_dynpro using 'SAPLAIST' '0100'.

perform bdc_field using 'BDC_CURSOR'

'ANLA-ANLN1'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

<b>perform bdc_field using 'ANLA-ANLN1'

I_ANLA-ANLN1.</b>

perform bdc_field using 'ANLA-ANLN2'

'0'.

<b>perform bdc_field using 'ANLA-BUKRS'

I_ANLA-BUKRS.</b>

perform bdc_dynpro using 'SAPLAIST' '1000'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BDC_CURSOR'

'ANLA-TXT50'.

<b>perform bdc_field using 'ANLA-TXT50'

I_ANLA-TXT50.</b>

perform bdc_field using 'ANLA-MENGE'

'1'.

perform bdc_field using 'ANLA-MEINS'

'EA'.

perform bdc_field using 'RA02S-XHIST'

'X'.

perform bdc_field using 'ANLA-AKTIV'

'12/02/2006'.

perform bdc_dynpro using 'SAPLAIST' '1000'.

perform bdc_field using 'BDC_OKCODE'

'=BUCH'.

perform bdc_field using 'BDC_CURSOR'

'ANLA-TXT50'.

perform bdc_field using 'ANLA-TXT50'

'Aircondition TEST CC516'.

perform bdc_field using 'ANLA-MENGE'

'1'.

perform bdc_field using 'ANLA-MEINS'

'EA'.

perform bdc_field using 'RA02S-XHIST'

'X'.

perform bdc_field using 'ANLA-AKTIV'

'12/02/2006'.

perform bdc_transaction using 'AS02'.

i hope your problem will solve...

Azhar