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

Former Member
0 Likes
950

REPORT Y180DM02.

PARAMETERS:

OUTFILE(20) DEFAULT ‘’c:/pg.txt" LOWER CASE,

STATE LIKE KNA1-REGIO DEFAULT ‘MA’.

DATA: BEGIN OF OUTREC,

KUNNR LIKE KNA1-KUNNR,

REGIO LIKE KNA1-REGIO,

TELF1 LIKE KNA1-TELF1,

END OF OUTREC.

data:out_itab type standard table of outrec initial size 0 with header line.

SELECT KUNNR REGIO TELF1 FROM KNA1 INTO CORRESPONDING FIELDS OF OUT_itab where regio = state.

open datset outfile for output in text mode.

TRANSFER OUT_itab TO OUTFILE.

CLOSE DATASET OUTFILE.

the program creates the file to application server but no data is transferred.pls tell me what is the problem.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
928

hi,

you forgot to use loop at itab.

transfer...........

endloop.

check this one.

REPORT ZSR_BDC_OPEN.

.

TABLES : LFA1.

SELECT-OPTIONS : S_LIFNR FOR LFA1-LIFNR.

PARAMETERS : FILE(200) TYPE C.

DATA : BEGIN OF ITAB OCCURS 0,

LIFNR LIKE LFA1-LIFNR,

LAND1 LIKE LFA1-LAND1,

END OF ITAB.

SELECT LIFNR LAND1 FROM KNA1 INTO TABLE ITAB WHERE LIFNR IN S_LIFNR.

OPEN DATASET FILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

LOOP AT ITAB FROM 1 TO 5.

TRANSFER ITAB TO FILE.

ENDLOOP.

IF SY-SUBRC = 8.

WRITE 😕 'not created'.

ENDIF.

CLOSE DATASET FILE.

LOOP AT ITAB.

WRITE 😕 ITAB-LIFNR,ITAB-LAND1.

ENDLOOP.

WRITE 😕 'hai'.

REFRESH ITAB.

12 REPLIES 12
Read only

anversha_s
Active Contributor
0 Likes
928

hi,

chk this sample 1.

TYPE-POOLS:TRUXS.

DATA: BEGIN OF ITAB OCCURS 0,    
 VBELNLIKE VBAP-VBELN,     
 POSNR LIKE VBAP-POSNR,      
END OF ITAB.

DATA:ITAB1 TYPE TRUXS_T_TEXT_DATA.
SELECT VBELN  POSNR         
UP TO10 ROWS         
FROM VBAP         
INTO TABLE ITAB.

CALL FUNCTION  'SAP_CONVERT_TO_CSV_FORMAT'  
EXPORTING    
I_FIELD_SEPERATOR    = ';'  
TABLES    
I_TAB_SAP_DATA       = ITAB  
CHANGING    
I_TAB_CONVERTED_DATA = ITAB1  
EXCEPTIONS    
CONVERSION_FAILED    = 1    
OTHERS               = 2.

IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO         
WITH SY-MSGV1SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CALL FUNCTION 'GUI_DOWNLOAD'  
EXPORTING    
FILENAME = 'C:TEMPtest.txt' 
 TABLES    
DATA_TAB = ITAB1  
EXCEPTIONS    
OTHERS   = 1.

Rgds

Anversha

Read only

0 Likes
928

Why do i need to complicate the matter?If i use select * and then move-corresponding to itab,the code is working fine.but my aim is to avoid select * usage .i want to use only one select.so how to do it that way?

Read only

Former Member
0 Likes
928

Hi,

use GUI_DOWNLOAD fro down load itab.

CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
*   BIN_FILESIZE                    =
    filename                        = 'C:temp.txt'
  tables
    data_tab                        = out_itab.

Jogdand M B

Read only

0 Likes
928

Hi,

This codes will work, check it not need of open dataset:

REPORT Y180DM02.
PARAMETERS:
OUTFILE(20) DEFAULT ’c:/pg.txt' , " LOWER CASE,
STATE LIKE KNA1-REGIO DEFAULT ‘MA’.
DATA: BEGIN OF OUTREC,
KUNNR LIKE KNA1-KUNNR,
REGIO LIKE KNA1-REGIO,
TELF1 LIKE KNA1-TELF1,
END OF OUTREC.
data:out_itab type standard table of outrec initial size 0 with header line.
SELECT KUNNR REGIO TELF1 FROM KNA1 INTO tbale OUT_itab where regio = state.

CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
*   BIN_FILESIZE                    =
    filename                        = OUTFILE
  tables
    data_tab                        = out_itab.

Jogdand M B

Message was edited by:

Jogdand M B

Read only

0 Likes
928

hi boss, gui download and upload are used for downloading and uploading to/from local server,not from application server.my job is related to application server.pls check out.

Read only

Former Member
0 Likes
928

Hi Priyankush,

you need to loop the table and then use the transfer as a single record gets transferred to appln file with the transfer statement.

open datset outfile for output in text mode.

<b>loop at out_itab.</b>

TRANSFER OUT_itab TO OUTFILE.

<b>endloop.</b>

CLOSE DATASET OUTFILE

Regards,

Vidya.

Read only

Former Member
0 Likes
929

hi,

you forgot to use loop at itab.

transfer...........

endloop.

check this one.

REPORT ZSR_BDC_OPEN.

.

TABLES : LFA1.

SELECT-OPTIONS : S_LIFNR FOR LFA1-LIFNR.

PARAMETERS : FILE(200) TYPE C.

DATA : BEGIN OF ITAB OCCURS 0,

LIFNR LIKE LFA1-LIFNR,

LAND1 LIKE LFA1-LAND1,

END OF ITAB.

SELECT LIFNR LAND1 FROM KNA1 INTO TABLE ITAB WHERE LIFNR IN S_LIFNR.

OPEN DATASET FILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

LOOP AT ITAB FROM 1 TO 5.

TRANSFER ITAB TO FILE.

ENDLOOP.

IF SY-SUBRC = 8.

WRITE 😕 'not created'.

ENDIF.

CLOSE DATASET FILE.

LOOP AT ITAB.

WRITE 😕 ITAB-LIFNR,ITAB-LAND1.

ENDLOOP.

WRITE 😕 'hai'.

REFRESH ITAB.

Read only

0 Likes
928

IT IS WORKING.THANKS,

Read only

0 Likes
928

HOW TO USE CALL TRANSACTION FOR READING FROM A DATASET(FILE IN APPLICATION SERVER)?

Read only

0 Likes
928

WHATS THE USE OF CLEAR IN LAST LINE.IT IS SHOWING THE SAME O/P EVEN WITH REFRESH.??

Read only

0 Likes
928

Sudha,

When I retrieve the .CSV file the negative amount has the following the decimals. eg 34.56-. How can I fix this so that in the .CSV file the appears before the number.

Appreciate any help

Xavier

Read only

Former Member
0 Likes
928

i am facing aproblem....when i am processing my session created through sm35,it is showing the session is locked.....pls tell what to do..the update is going on well through call transaction