‎2008 Aug 07 7:45 AM
Following is my code.
REPORT Z_DEX_SS_CUSTOMER_CREATE.
tables:zcustomer,ztransform.
data:itab_bapiname like ztransform occurs 10 with header line.
data:gs_return like bapireturn1,
gs_customerno like bapikna103-customer,
gs_bapikna101_1 like table of bapikna101_1 with header line,
gs_bapikna101_1_gwa like bapikna101_1,
gs_bapikna105 like table of bapikna105 with header line,
gs_bapikna105_gwa like bapikna105,
gs_bapikna106 like table of bapikna106 with header line,
gs_bapikna106_gwa like bapikna106,
gs_bapikna102 like table of bapikna102 with header line,
gs_bapikna102_gwa like bapikna102.
data:offset_data(10) value 0.
*Dynamic program table definition
data: begin of dyntabl occurs 10,
line(200),
end of dyntabl.
data:dynlength(3).
Temporary spec table
data:begin of spec_initial occurs 10,
row(150),
end of spec_initial.
Specification table decleration
data:begin of spec occurs 10,
fieldname(20),
field_type(20),
field_length(20),
field_offset(20),
sap_fieldname(30),
end of spec.
data:cust_bapiname(30).
*Temporary item data table decleration
data:begin of temp_data_table occurs 10,
line(3000),
end of temp_data_table.
*Final item data table decleration
data:data_table like zcustomer occurs 10 with header line.
call function 'UPLOAD'
exporting
filename = 'D:\SAPSWITCH\Customer files\custspec1.TXT'
filetype = 'ASC'
HAS_FIELD_SEPARATOR = ' '
HEADER_LENGTH = 0
tables
data_tab = spec_initial
exceptions
file_open_error = 2.
loop at spec_initial.
split spec_initial-row at ' ' into spec-fieldname spec-field_type spec-field_length spec-field_offset spec-sap_fieldname.
append spec.
insert into zspec_CUSTOMER values spec.
endloop.
*Uploading the Data File.
call function 'UPLOAD'
exporting
filename = 'D:\SAPSWITCH\Customer files\customerdata.TXT'
filetype = 'ASC'
HAS_FIELD_SEPARATOR = ' '
HEADER_LENGTH = 0
tables
data_tab = temp_data_table
exceptions
file_open_error = 2.
Transfering values from the item data flat file to the internal table
delete from zcustomer.
loop at temp_data_table.
loop at spec.
data_tableoffset_data = temp_data_tablespec-field_offset(spec-field_length).
offset_data = offset_data + 40.
endloop.
append data_table.
insert into zcustomer values data_table.
offset_data = 0.
endloop.
select * from ztransform into table itab_bapiname.
*Moving values to the Bapi fields dynamically
dyntabl-line = 'program zdynpro.'. append dyntabl.
dyntabl-line = 'tables:zcustomer.'.append dyntabl.
dyntabl-line = 'Data:itab_data like zcustomer occurs 10 with header line.'.append dyntabl.
dyntabl-line = 'Data:gs_bapikna101_1 like table of bapikna101_1 with header line,'.append dyntabl.
dyntabl-line = 'gs_bapikna105 like table of bapikna105 with header line,'.append dyntabl.
dyntabl-line = 'gs_bapikna106 like table of bapikna106 with header line,'.append dyntabl.
dyntabl-line = 'gs_bapikna102 like table of bapikna102 with header line,'.append dyntabl.
dyntabl-line = 'offset_data(10) value 0.'.append dyntabl.
dyntabl-line = 'select * from zcustomer into table itab_data.'.append dyntabl.
dyntabl-line = 'LOOP AT ITAB_data.'.append dyntabl.
loop at spec.
loop at itab_bapiname where sap_field = spec-sap_fieldname.
cust_bapiname = itab_bapiname-bapi_field.
endloop.
dyntabl-line = cust_bapiname.
dynlength = strlen( dyntabl-line ).
dynlength = dynlength + 1.
dyntabl-line+dynlength = '='.
dynlength = dynlength + 2.
dyntabl-linedynlength = 'itab_dataoffset_data(40).'.
*dynlength = strlen( dyntabl-line ).
*dyntabl-line+dynlength = '.'.
append dyntabl.
dyntabl-line = 'offset_data = offset_data + 40.'.append dyntabl.
endloop.
dyntabl-line = 'offset_data = 0.'.
dyntabl-line = 'append gs_bapikna105. append gs_bapikna106. append gs_bapikna102.'.append dyntabl.
dyntabl-line = 'endloop.'.append dyntabl.
dyntabl-line = 'export gs_bapikna101_1 gs_bapikna105 gs_bapikna106 gs_bapikna102 TO MEMORY ID ''DEX''.'.append dyntabl.
insert report 'zdynpro' from dyntabl.
submit zdynpro and return.
*LOOP AT DYNTABL.
WRITE DYNTABL.
ENDLOOP.
import gs_bapikna101_1 gs_bapikna105 gs_bapikna106 gs_bapikna102 from MEMORY ID 'DEX'.
loop at gs_bapikna101_1 from 1 to 1 into gs_bapikna101_1_gwa.
endloop.
loop at gs_bapikna105 from 1 to 1 into gs_bapikna105_gwa.
endloop.
loop at gs_bapikna102 from 1 to 1 into gs_bapikna102_gwa.
endloop.
The section under consideration ive made bold and italised it.
Im calling another program dynamically and in that program im exporting some date to the sap memory.However when i import it from my program im unable to view the values. Why is that?
‎2008 Aug 07 7:51 AM
Hi Friend,
Below is an example for successfully using IMPORT and EXPORT:
IMPORT ws_samepo TO loc_x FROM MEMORY ID 'SAMEPO'.*
EXPORT ws_samepo = loc_x TO MEMORY ID 'SAMEPO'.
Pleaes use same variable name for IMPORT and EXPORT.
Hope it will help you.
Regards
Krishnendu
‎2008 Aug 07 8:03 AM
Ive used the syntax which i mentioned before and it works absolutely fine.
Are you sure in the import statement there is import to?
And does that variable have to be defined?
‎2008 Aug 07 8:04 AM
Hi Dexter,
Check if memory ID is same while EXPORT AND IMPORT.
Also check field types are same and in same order in both EXPORT AND IMPORT.
Can you check what is sy-subrc before IMPORT.
It will be also good to check if sy-subrc is 0 after EXPORT in debug mode.
Regards,
Mohaiyuddin
‎2008 Aug 07 8:35 AM
Hi Friend,
Yes to will be there.
And you have to define those variables.
Hope it will work fine.
Regards
Krishnendu
‎2008 Aug 07 8:37 AM
‎2008 Aug 07 8:43 AM
Thanks guys.
Sorry but it was a silly mistake on m,y part and not a syntax error