2006 Sep 26 4:12 PM
hi friends,
Could u please tell me how to do this
i friends i am wroking on interface
this is the program it is not showing any syntatical errors i am able to open the logical file .
and when i tried to download the physical file nothing is being downloaded
i am getting an error like "error in open the downloaded file".
Could u suggest where i went wrong.
tables : knb1, "customer master (companycode)
kna1, "genaral data in customer master
knvp. "customer master partener functions
zvarv. "Program Hard Coded Values support table
----
----
TYPE-POOLS DEFINATION
----
type-pools : slis.
----
----
TYPES DECLARATION
----
Customer Master Company code Data
types : begin of t_knb1,
kunnr like knb1-kunnr,
akont like knb1-akont,
end of t_knb1.
data : i_knb1 type t_knb1 occurs 0 with header line .
Customer Master
types : begin of t_kna1,
kunnr like kna1-kunnr,
name1 like kna1-name1,
stras like kna1-stras,
ort01 like kna1-ort01,
stcd1 like kna1-stcd1,
pstlz like kna1-pstlz,
end of t_kna1.
data : i_kna1 type t_kna1 occurs 0 with header line.
Customer Partner Functions
types : begin of t_knvp,
kunnr like knvp-kunnr,
vkorg like knvp-vkorg,
parvw like knvp-parvw,
kunn2 like knvp-kunn2,
end of t_knvp.
data : i_knvp type t_knvp occurs 0 with header line.
Output data
types : begin of t_output,
recordtype type c,
soldtocust(10) type c,
payer(10) type c,
sequence(5) type n,
custname(35) type c,
custaddress(35) type c,
custcity(35) type c,
taxid(16) type c,
postalcode(5) type c,
branch type c,
delivery(3) type c,
end of t_output.
data : i_output type t_output occurs 0 with header line.
ZVARV Table
*types : begin of t_zvarv,
zobject1 like zvarv-zobject1,
zobject2 like zvarv-zobject2,
zseqnumb like zvarv-zseqnumb,
zobjval like zvarv-zobjval,
end of t_zvarv.
*
*data : i_zvarv type t_zvarv occurs 0 with header line.
*
*
Error messages and total records
types : begin of t_error_log,
message(200) type c,
end of t_error_log.
data : i_error_log type t_error_log occurs 0 with header line.
Field catalog
data : t_fieldcat_tab type slis_t_fieldcat_alv with header line.
----
----
Variables
----
data : v_sequence(5) type n, "Total records
v_line type i, "Message
v_count type i, "Counter for KNA1 records
v_count1 type i, "Counter for KNVP records
v_result(100) type c, "Totals for KNA1
v_result1(100) type c, "Totals for KNVP
v_vkorg like knvp-vkorg, "Message for Validation
v_pfile(40) type c.
----
----
Constants
----
data : c_program(30) type c value 'ZSDI0215', " Program Name
c_parvw_rg like knvp-parvw value 'RG', "Partner type
c_aufsd(2) type c value 'CD'. "Central order block for Cust
----
----
Selection-screen
----
selection-screen begin of block b1 with frame title text-001.
parameters : p_vkorg like knvp-vkorg obligatory. "Sales Org
select-options : s_akont for knb1-akont obligatory default
'0001050100'. "Reconciliation Account
selection-screen end of block b1.
selection-screen begin of block b2 with frame title text-002.
parameters : p_alv as checkbox,
p_df as checkbox.
selection-screen end of block b2.
selection-screen begin of block b3 with frame title text-003.
parameters : p_lfile like filetextci-fileintern
default 'Z_IO01989_CUSTOMER_MASTER_DATA', " Logical file
p_pfile like rfpdo-rfbifile. " Physical File
selection-screen end of block b3.
----
----
At selection-screen
----
at selection-screen on p_vkorg.
Validation of Sales Organization
select single vkorg
into v_vkorg
from tvko
where vkorg = p_vkorg.
if v_vkorg is initial.
message e045 with text-030.
endif.
----
----
Start-of-selection
----
start-of-selection.
Fetch data
perform get_data.
Processing the data
perform process_data.
----
----
End-of-Selection
----
end-of-selection.
if p_alv eq 'X'.
Field catalog
perform f_prepare_fieldcat.
Disply alv report
perform f_display_report.
Disply error log
perform f_error_log.
elseif p_df eq 'X'.
Disply logical file & physical file
perform f_logical_file.
perform f_physical_file.
else.
Display the list
perform f_list_display.
Disply logical file & physical file
perform f_logical_file.
perform f_physical_file.
endif.
----
----
Form get_data
----
Fetch data and store in internal tables
----
form get_data .
Get zvarv data.
perform get_zvarv.
Get knb1 data
perform get_knb1.
Get kna1 data
perform get_kna1.
Get knvp data
perform get_knvp.
endform. " get_data
----
----
form get_zvarv
----
zvarv data
----
form get_zvarv .
Fetch data from zvarv.
select zobject1 zobject2 zseqnumb zobjval
from zvarv
into table i_zvarv
where zobject1 eq c_program.
*
sort i_zvarv by zobject2.
endform. " get_zvarv
----
----
form get_knb1
----
Get KNB1 data
----
form get_knb1 .
Fetch data from knb1.
select kunnr akont
from knb1
into table i_knb1
where akont in s_akont.
describe table i_knb1 lines v_line.
endform. " get_knb1
----
----
Form get_kna1
----
Get KNB1 data
----
form get_kna1 .
Fetch data from kna1.
select kunnr name1 stras ort01 stcd1 pstlz
from kna1
into table i_kna1
for all entries in i_knb1
where kunnr = i_knb1-kunnr and
aufsd ne 'cd'."v_aufsd.
endform. " get_kna1
----
----
Form get_knvp
----
Get KNVP data
----
form get_knvp .
Fetch data from knvp
select kunnr parvw kunn2 vkorg
from knvp
into table i_knvp
for all entries in i_knb1
where kunnr = i_knb1-kunnr
and vkorg = p_vkorg
and parvw = c_parvw_rg.
endform. " get_knvp
----
----
Form process_data
----
Processing output data
----
form process_data .
Get AUFSD value from ZVARV
perform zvarv_read.
loop at i_knb1.
read table i_kna1 with key kunnr = i_knb1-kunnr.
if sy-subrc ne 0.
concatenate: 'in kna1 no record found for Customer number'
i_knb1-kunnr
into v_result separated by space.
move v_result to i_error_log-message.
append i_error_log.
v_count = v_count + 1.
else.
Move the kna1 data to output
move : i_kna1-name1 to i_output-custname,
i_kna1-stras to i_output-custaddress,
i_kna1-ort01 to i_output-custcity,
i_kna1-stcd1 to i_output-taxid,
i_kna1-pstlz to i_output-postalcode.
*append i_output.
*endif.
read table i_knvp with key kunnr = i_knb1-kunnr.
if sy-subrc <> 0.
concatenate : 'in knvp no record found for customer number'
i_knb1-kunnr
into v_result1 separated by space.
move v_result1 to i_error_log-message.
append i_error_log.
v_count1 = v_count1 + 1.
else.
Move the knvp data to output
loop at i_knvp where kunnr eq i_knb1-kunnr.
move : i_knvp-kunnr to i_output-soldtocust,
i_knvp-kunn2 to i_output-payer.
v_sequence = v_sequence + 1.
Move non table related data to output
move : 'C' to i_output-recordtype,
v_sequence to i_output-sequence,
'1' to i_output-branch,
'ABC' to i_output-delivery.
append i_output.
endloop.
endif.
endif.
endloop.
endform. " process_data
----
----
Form zvarv_read
----
Read AUFSD value from ZVARV
----
form zvarv_read .
clear i_zvarv.
read table i_zvarv with key zobject2 = c_aufsd
binary search.
if sy-subrc eq 0.
move i_zvarv-zobjval to v_aufsd.
endif.
endform.
----
----
Form f_prepare_fieldcat
----
Field catalog preparation
----
Field catalog preparation
form f_prepare_fieldcat .
t_fieldcat_tab-col_pos = 1.
t_fieldcat_tab-tabname = 'I_OUTPUT'.
t_fieldcat_tab-fieldname = 'RECORDTYPE'.
t_fieldcat_tab-seltext_l = 'Record type'.
append t_fieldcat_tab.
t_fieldcat_tab-col_pos = 2.
t_fieldcat_tab-tabname = 'I_OUTPUT'.
t_fieldcat_tab-fieldname = 'SOLDTOCUST'.
t_fieldcat_tab-seltext_l = 'Sold to custmer'.
append t_fieldcat_tab.
t_fieldcat_tab-col_pos = 3.
t_fieldcat_tab-tabname = 'I_OUTPUT'.
t_fieldcat_tab-fieldname = 'PAYER'.
t_fieldcat_tab-seltext_l = 'payer'.
append t_fieldcat_tab.
t_fieldcat_tab-col_pos = 4.
t_fieldcat_tab-tabname = 'I_OUTPUT'.
t_fieldcat_tab-fieldname = 'SEQUENCE'.
t_fieldcat_tab-seltext_l = 'Sequence Number'.
append t_fieldcat_tab.
t_fieldcat_tab-col_pos = 5.
t_fieldcat_tab-tabname = 'I_OUTPUT'.
t_fieldcat_tab-fieldname = 'CUSTNAME'.
t_fieldcat_tab-seltext_l = 'Customer Name'.
append t_fieldcat_tab.
t_fieldcat_tab-col_pos = 6.
t_fieldcat_tab-tabname = 'I_OUTPUT'.
t_fieldcat_tab-fieldname = 'CUSTADDRESS'.
t_fieldcat_tab-seltext_l = 'Customer Address'.
append t_fieldcat_tab.
t_fieldcat_tab-col_pos = 7.
t_fieldcat_tab-tabname = 'I_OUTPUT'.
t_fieldcat_tab-fieldname = 'CUSTCITY'.
t_fieldcat_tab-seltext_l = 'Customer City'.
append t_fieldcat_tab.
t_fieldcat_tab-col_pos = 8.
t_fieldcat_tab-tabname = 'I_OUTPUT'.
t_fieldcat_tab-fieldname = 'TAXID'.
t_fieldcat_tab-seltext_l = 'Tax id'.
append t_fieldcat_tab.
t_fieldcat_tab-col_pos = 9.
t_fieldcat_tab-tabname = 'I_OUTPUT'.
t_fieldcat_tab-fieldname = 'POSTALCODE'.
t_fieldcat_tab-seltext_l = 'Postal code'.
append t_fieldcat_tab.
t_fieldcat_tab-col_pos = 10.
t_fieldcat_tab-tabname = 'I_OUTPUT'.
t_fieldcat_tab-fieldname = 'BRANCH'.
t_fieldcat_tab-seltext_l = 'Branch'.
append t_fieldcat_tab.
t_fieldcat_tab-col_pos = 11.
t_fieldcat_tab-tabname = 'I_OUTPUT'.
t_fieldcat_tab-fieldname = 'DELIVERY'.
t_fieldcat_tab-seltext_l = 'Delivery'.
append t_fieldcat_tab.
endform. " f_prepare_fieldcat
----
----
Form f_display_report
----
Display the ALV output
----
To display the ALV report
form f_display_report .
data : l_repid like sy-repid.
l_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
i_buffer_active = 'X'
i_callback_program = l_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT =
it_fieldcat = t_fieldcat_tab[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
i_default = 'X'
i_save = 'A'
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = i_output[]
EXCEPTIONS
program_error = 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. " f_display_report
----
----
Form f_error_log
----
Display Error records
----
Display error records
form f_error_log .
if not i_error_log is initial.
write : / 'ERROR RECORDS'.
loop at i_error_log. .
write : / i_error_log-message.
endloop.
skip 1.
endif.
write : / 'Number of KNB1 values found ', v_line,
/ 'Number of KNA1 values not found ', v_count,
/ 'Number of KNVP values not found ', v_count1.
endform. " f_error_log
----
----
Form f_list_display
----
Display the list
----
Display the list
form f_list_display .
uline.
write : /1 sy-vline, 2 'Recordtype',
13 sy-vline, 14 'Soldtocust',
28 sy-vline, 29 'payer',
40 sy-vline, 41 'Sequence',
56 sy-vline, 57 'Custname',
70 sy-vline, 71 'custadress',
84 sy-vline, 85 'Custcity',
98 sy-vline, 99 'Taxid',
115 sy-vline, 116 'Postalcode',
130 sy-vline, 131 'Branch',
150 sy-vline, 151 'Delivary',
170 sy-vline.
uline.
loop at i_output.
write : /1 sy-vline, 2 i_output-recordtype,
13 sy-vline, 14 i_output-soldtocust,
28 sy-vline, 29 i_output-payer,
40 sy-vline, 41 i_output-sequence,
56 sy-vline, 57 i_output-custname,
70 sy-vline, 71 i_output-custaddress,
84 sy-vline, 85 i_output-custcity,
98 sy-vline, 99 i_output-taxid,
115 sy-vline, 116 i_output-postalcode,
130 sy-vline, 131 i_output-branch,
150 sy-vline, 151 i_output-delivery,
170 sy-vline.
uline.
clear : i_output.
endloop.
endform. " f_list_display
----
----
Form f_logical_file
----
Move data to logical file
----
form f_logical_file .
Move data to logical file
open dataset P_lFILE for output in text mode encoding default.
loop at i_output.
transfer i_output to p_lfile.
endloop.
close dataset p_lfile.
endform. " f_logical_file
----
----
Form f_physical_file
----
Move data to physical file
----
form f_physical_file .
Move data to physical file
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = p_pfile
FILETYPE = 'ASC'
TABLES
DATA_TAB = i_output
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
INVALID_FILESIZE = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
NO_AUTHORITY = 10
OTHERS = 11.
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. " f_physical_file
regards
harshavi
hi friends,
Could u please tell me how to do this
i friends i am wroking on interface
this is the program it is not showing any syntatical errors i am able to open the logical file .
and when i tried to download the physical file nothing is being downloaded
i am getting an error like "error in open the downloaded file".
Could u suggest where i went wrong.
tables : knb1, "customer master (companycode)
kna1, "genaral data in customer master
knvp. "customer master partener functions
zvarv. "Program Hard Coded Values support table
----
----
TYPE-POOLS DEFINATION
----
type-pools : slis.
----
----
TYPES DECLARATION
----
Customer Master Company code Data
types : begin of t_knb1,
kunnr like knb1-kunnr,
akont like knb1-akont,
end of t_knb1.
data : i_knb1 type t_knb1 occurs 0 with header line .
Customer Master
types : begin of t_kna1,
kunnr like kna1-kunnr,
name1 like kna1-name1,
stras like kna1-stras,
ort01 like kna1-ort01,
stcd1 like kna1-stcd1,
pstlz like kna1-pstlz,
end of t_kna1.
data : i_kna1 type t_kna1 occurs 0 with header line.
Customer Partner Functions
types : begin of t_knvp,
kunnr like knvp-kunnr,
vkorg like knvp-vkorg,
parvw like knvp-parvw,
kunn2 like knvp-kunn2,
end of t_knvp.
data : i_knvp type t_knvp occurs 0 with header line.
Output data
types : begin of t_output,
recordtype type c,
soldtocust(10) type c,
payer(10) type c,
sequence(5) type n,
custname(35) type c,
custaddress(35) type c,
custcity(35) type c,
taxid(16) type c,
postalcode(5) type c,
branch type c,
delivery(3) type c,
end of t_output.
data : i_output type t_output occurs 0 with header line.
ZVARV Table
*types : begin of t_zvarv,
zobject1 like zvarv-zobject1,
zobject2 like zvarv-zobject2,
zseqnumb like zvarv-zseqnumb,
zobjval like zvarv-zobjval,
end of t_zvarv.
*
*data : i_zvarv type t_zvarv occurs 0 with header line.
*
*
Error messages and total records
types : begin of t_error_log,
message(200) type c,
end of t_error_log.
data : i_error_log type t_error_log occurs 0 with header line.
Field catalog
data : t_fieldcat_tab type slis_t_fieldcat_alv with header line.
----
----
Variables
----
data : v_sequence(5) type n, "Total records
v_line type i, "Message
v_count type i, "Counter for KNA1 records
v_count1 type i, "Counter for KNVP records
v_result(100) type c, "Totals for KNA1
v_result1(100) type c, "Totals for KNVP
v_vkorg like knvp-vkorg, "Message for Validation
v_pfile(40) type c.
----
----
Constants
----
data : c_program(30) type c value 'ZSDI0215', " Program Name
c_parvw_rg like knvp-parvw value 'RG', "Partner type
c_aufsd(2) type c value 'CD'. "Central order block for Cust
----
----
Selection-screen
----
selection-screen begin of block b1 with frame title text-001.
parameters : p_vkorg like knvp-vkorg obligatory. "Sales Org
select-options : s_akont for knb1-akont obligatory default
'0001050100'. "Reconciliation Account
selection-screen end of block b1.
selection-screen begin of block b2 with frame title text-002.
parameters : p_alv as checkbox,
p_df as checkbox.
selection-screen end of block b2.
selection-screen begin of block b3 with frame title text-003.
parameters : p_lfile like filetextci-fileintern
default 'Z_IO01989_CUSTOMER_MASTER_DATA', " Logical file
p_pfile like rfpdo-rfbifile. " Physical File
selection-screen end of block b3.
----
----
At selection-screen
----
at selection-screen on p_vkorg.
Validation of Sales Organization
select single vkorg
into v_vkorg
from tvko
where vkorg = p_vkorg.
if v_vkorg is initial.
message e045 with text-030.
endif.
----
----
Start-of-selection
----
start-of-selection.
Fetch data
perform get_data.
Processing the data
perform process_data.
----
----
End-of-Selection
----
end-of-selection.
if p_alv eq 'X'.
Field catalog
perform f_prepare_fieldcat.
Disply alv report
perform f_display_report.
Disply error log
perform f_error_log.
elseif p_df eq 'X'.
Disply logical file & physical file
perform f_logical_file.
perform f_physical_file.
else.
Display the list
perform f_list_display.
Disply logical file & physical file
perform f_logical_file.
perform f_physical_file.
endif.
----
----
Form get_data
----
Fetch data and store in internal tables
----
form get_data .
Get zvarv data.
perform get_zvarv.
Get knb1 data
perform get_knb1.
Get kna1 data
perform get_kna1.
Get knvp data
perform get_knvp.
endform. " get_data
----
----
form get_zvarv
----
zvarv data
----
form get_zvarv .
Fetch data from zvarv.
select zobject1 zobject2 zseqnumb zobjval
from zvarv
into table i_zvarv
where zobject1 eq c_program.
*
sort i_zvarv by zobject2.
endform. " get_zvarv
----
----
form get_knb1
----
Get KNB1 data
----
form get_knb1 .
Fetch data from knb1.
select kunnr akont
from knb1
into table i_knb1
where akont in s_akont.
describe table i_knb1 lines v_line.
endform. " get_knb1
----
----
Form get_kna1
----
Get KNB1 data
----
form get_kna1 .
Fetch data from kna1.
select kunnr name1 stras ort01 stcd1 pstlz
from kna1
into table i_kna1
for all entries in i_knb1
where kunnr = i_knb1-kunnr and
aufsd ne 'cd'."v_aufsd.
endform. " get_kna1
----
----
Form get_knvp
----
Get KNVP data
----
form get_knvp .
Fetch data from knvp
select kunnr parvw kunn2 vkorg
from knvp
into table i_knvp
for all entries in i_knb1
where kunnr = i_knb1-kunnr
and vkorg = p_vkorg
and parvw = c_parvw_rg.
endform. " get_knvp
----
----
Form process_data
----
Processing output data
----
form process_data .
Get AUFSD value from ZVARV
perform zvarv_read.
loop at i_knb1.
read table i_kna1 with key kunnr = i_knb1-kunnr.
if sy-subrc ne 0.
concatenate: 'in kna1 no record found for Customer number'
i_knb1-kunnr
into v_result separated by space.
move v_result to i_error_log-message.
append i_error_log.
v_count = v_count + 1.
else.
Move the kna1 data to output
move : i_kna1-name1 to i_output-custname,
i_kna1-stras to i_output-custaddress,
i_kna1-ort01 to i_output-custcity,
i_kna1-stcd1 to i_output-taxid,
i_kna1-pstlz to i_output-postalcode.
*append i_output.
*endif.
read table i_knvp with key kunnr = i_knb1-kunnr.
if sy-subrc <> 0.
concatenate : 'in knvp no record found for customer number'
i_knb1-kunnr
into v_result1 separated by space.
move v_result1 to i_error_log-message.
append i_error_log.
v_count1 = v_count1 + 1.
else.
Move the knvp data to output
loop at i_knvp where kunnr eq i_knb1-kunnr.
move : i_knvp-kunnr to i_output-soldtocust,
i_knvp-kunn2 to i_output-payer.
v_sequence = v_sequence + 1.
Move non table related data to output
move : 'C' to i_output-recordtype,
v_sequence to i_output-sequence,
'1' to i_output-branch,
'ABC' to i_output-delivery.
append i_output.
endloop.
endif.
endif.
endloop.
endform. " process_data
----
----
Form zvarv_read
----
Read AUFSD value from ZVARV
----
form zvarv_read .
clear i_zvarv.
read table i_zvarv with key zobject2 = c_aufsd
binary search.
if sy-subrc eq 0.
move i_zvarv-zobjval to v_aufsd.
endif.
endform.
----
----
Form f_prepare_fieldcat
----
Field catalog preparation
----
Field catalog preparation
form f_prepare_fieldcat .
t_fieldcat_tab-col_pos = 1.
t_fieldcat_tab-tabname = 'I_OUTPUT'.
t_fieldcat_tab-fieldname = 'RECORDTYPE'.
t_fieldcat_tab-seltext_l = 'Record type'.
append t_fieldcat_tab.
t_fieldcat_tab-col_pos = 2.
t_fieldcat_tab-tabname = 'I_OUTPUT'.
t_fieldcat_tab-fieldname = 'SOLDTOCUST'.
t_fieldcat_tab-seltext_l = 'Sold to custmer'.
append t_fieldcat_tab.
t_fieldcat_tab-col_pos = 3.
t_fieldcat_tab-tabname = 'I_OUTPUT'.
t_fieldcat_tab-fieldname = 'PAYER'.
t_fieldcat_tab-seltext_l = 'payer'.
append t_fieldcat_tab.
t_fieldcat_tab-col_pos = 4.
t_fieldcat_tab-tabname = 'I_OUTPUT'.
t_fieldcat_tab-fieldname = 'SEQUENCE'.
t_fieldcat_tab-seltext_l = 'Sequence Number'.
append t_fieldcat_tab.
t_fieldcat_tab-col_pos = 5.
t_fieldcat_tab-tabname = 'I_OUTPUT'.
t_fieldcat_tab-fieldname = 'CUSTNAME'.
t_fieldcat_tab-seltext_l = 'Customer Name'.
append t_fieldcat_tab.
t_fieldcat_tab-col_pos = 6.
t_fieldcat_tab-tabname = 'I_OUTPUT'.
t_fieldcat_tab-fieldname = 'CUSTADDRESS'.
t_fieldcat_tab-seltext_l = 'Customer Address'.
append t_fieldcat_tab.
t_fieldcat_tab-col_pos = 7.
t_fieldcat_tab-tabname = 'I_OUTPUT'.
t_fieldcat_tab-fieldname = 'CUSTCITY'.
t_fieldcat_tab-seltext_l = 'Customer City'.
append t_fieldcat_tab.
t_fieldcat_tab-col_pos = 8.
t_fieldcat_tab-tabname = 'I_OUTPUT'.
t_fieldcat_tab-fieldname = 'TAXID'.
t_fieldcat_tab-seltext_l = 'Tax id'.
append t_fieldcat_tab.
t_fieldcat_tab-col_pos = 9.
t_fieldcat_tab-tabname = 'I_OUTPUT'.
t_fieldcat_tab-fieldname = 'POSTALCODE'.
t_fieldcat_tab-seltext_l = 'Postal code'.
append t_fieldcat_tab.
t_fieldcat_tab-col_pos = 10.
t_fieldcat_tab-tabname = 'I_OUTPUT'.
t_fieldcat_tab-fieldname = 'BRANCH'.
t_fieldcat_tab-seltext_l = 'Branch'.
append t_fieldcat_tab.
t_fieldcat_tab-col_pos = 11.
t_fieldcat_tab-tabname = 'I_OUTPUT'.
t_fieldcat_tab-fieldname = 'DELIVERY'.
t_fieldcat_tab-seltext_l = 'Delivery'.
append t_fieldcat_tab.
endform. " f_prepare_fieldcat
----
----
Form f_display_report
----
Display the ALV output
----
To display the ALV report
form f_display_report .
data : l_repid like sy-repid.
l_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
i_buffer_active = 'X'
i_callback_program = l_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT =
it_fieldcat = t_fieldcat_tab[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
i_default = 'X'
i_save = 'A'
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = i_output[]
EXCEPTIONS
program_error = 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. " f_display_report
----
----
Form f_error_log
----
Display Error records
----
Display error records
form f_error_log .
if not i_error_log is initial.
write : / 'ERROR RECORDS'.
loop at i_error_log. .
write : / i_error_log-message.
endloop.
skip 1.
endif.
write : / 'Number of KNB1 values found ', v_line,
/ 'Number of KNA1 values not found ', v_count,
/ 'Number of KNVP values not found ', v_count1.
endform. " f_error_log
----
----
Form f_list_display
----
Display the list
----
Display the list
form f_list_display .
uline.
write : /1 sy-vline, 2 'Recordtype',
13 sy-vline, 14 'Soldtocust',
28 sy-vline, 29 'payer',
40 sy-vline, 41 'Sequence',
56 sy-vline, 57 'Custname',
70 sy-vline, 71 'custadress',
84 sy-vline, 85 'Custcity',
98 sy-vline, 99 'Taxid',
115 sy-vline, 116 'Postalcode',
130 sy-vline, 131 'Branch',
150 sy-vline, 151 'Delivary',
170 sy-vline.
uline.
loop at i_output.
write : /1 sy-vline, 2 i_output-recordtype,
13 sy-vline, 14 i_output-soldtocust,
28 sy-vline, 29 i_output-payer,
40 sy-vline, 41 i_output-sequence,
56 sy-vline, 57 i_output-custname,
70 sy-vline, 71 i_output-custaddress,
84 sy-vline, 85 i_output-custcity,
98 sy-vline, 99 i_output-taxid,
115 sy-vline, 116 i_output-postalcode,
130 sy-vline, 131 i_output-branch,
150 sy-vline, 151 i_output-delivery,
170 sy-vline.
uline.
clear : i_output.
endloop.
endform. " f_list_display
----
----
Form f_logical_file
----
Move data to logical file
----
form f_logical_file .
Move data to logical file
open dataset P_lFILE for output in text mode encoding default.
loop at i_output.
transfer i_output to p_lfile.
endloop.
close dataset p_lfile.
endform. " f_logical_file
----
----
Form f_physical_file
----
Move data to physical file
----
form f_physical_file .
Move data to physical file
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = p_pfile
FILETYPE = 'ASC'
TABLES
DATA_TAB = i_output
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
INVALID_FILESIZE = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
NO_AUTHORITY = 10
OTHERS = 11.
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. " f_physical_file
regards
harshavi
2006 Sep 26 4:16 PM
declare
p_pfile like <b>RLGRAP-FILENAME</b>. "rfpdo-rfbifile. " Physical FileRegards,
Santosh
2006 Sep 26 4:17 PM
Hello,
I don't think there is any error in this code. Check the file path using the Tcode AL11.
If useful reward,
Vasanth
2006 Sep 26 4:21 PM
I don't see a problem with the code. What file name are you giving p_pfile?
Rob
2006 Sep 26 4:26 PM
hi Rob Burbank ,
file name is
p_pfile = c:\abc.txt
regards
harshavi
2006 Sep 26 4:30 PM
hi,
I guess it is enclosed in single quotes ..and make sure that file is not opened ..
i.e,
p_pfile = 'c:\abc.txt'.
REgards,
Santosh
2006 Sep 26 4:46 PM
Hi,
problem may be that file is already exist.
delete the file from directory or give new path.
or check authorization to create file in c: drive
Regards
amole
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |