Getting external IP with groovy

URL url = new URL("http://mkysoft.com/ip.php");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
InputStream is = connection.getInputStream();
return org.apache.commons.io.IOUtils.toString(is);

Update all items with impex

We canuse bactcmode for updating all items by type

UPDATE Product[batchmode=true];itemType(code)[unique=true];description[en][default='test']
;Product;
;VariantProduct;

Copy schema to another in Hana DB

You can get workfolder at backup console. Get destination folder and change backup as work for example.

export "SOURCESCHEMA"."*" as binary into '/workfolder' with replace threads 10;
import "SOURCESCHEMA"."*" as binary from '/workfolder' with rename schema "SOURCESCHEMA" to "TARGETSCHEMA";

If you get privilege error like “SAP DBTech JDBC: [258]: insufficient privilege: Not authorized”, edit your user at Security menu and add EXPORT/IMPORT System Privileges.

Install hybris temp/trial license

You can reset developer license with initializing. In initialize process all data deleted. You can install temp license without initialize. Use license.bat/license.sh for generating temp license. You can find this script at bin/platform. You need to create temp license by db. We have these options:

  • CPS_MYS = mysql
  • CPS_HDB = hana
  • CPS_ORA = oracle
  • CPS_MSS = mssql
  • CPS_POS = postgres
  • CPS_SQL = ?

For example we create temp license for mysql:
./license.sh -temp CPS_MYS

You will get temp license for 90 day.

You need remove old license after 90 day for new one. You can delete it with below command:
./license.sh -delete SystemID HardwareKey SoftwareProducts

You can get above parameters with below command:
./license.sh -get

— thanks to Yusuf for above information.

Also you can reset trial license with updating user creation time.

UPDATE users set createdTS = NOW()

NOTE: NOW() command for MySql, you must chose relevant command for your database. There is no option running update command on UI, you can develop groovy script for running this command over jdbc.

Change all table unload priority in hana

Change all table priority for unload in short time.

create procedure update_unload_priority() LANGUAGE SQLSCRIPT AS
CURSOR C_TABLE
FOR SELECT 'ALTER TABLE "' || TABLE_NAME || '" UNLOAD PRIORITY 9;' AS SQLTEXT
FROM SYS.TABLES
WHERE SCHEMA_NAME = 'MYSCHEMA' AND TABLE_TYPE = 'COLUMN' and temporary_table_type = 'NONE' AND unload_priority <> 9;
BEGIN
OPEN C_TABLE;
FOR cur_row AS C_TABLE DO
EXEC cur_row.SQLTEXT;
END FOR;
END;

Convert all row table to column in Hana

You can convert all row table to column table with below procedure:

create procedure convert_column() LANGUAGE SQLSCRIPT AS
CURSOR C_TABLE
FOR SELECT 'ALTER TABLE "' || TABLE_NAME || '" COLUMN;' AS SQLTEXT
FROM SYS.TABLES
WHERE SCHEMA_NAME = 'SAPABAP1' AND TABLE_TYPE = 'ROW' and temporary_table_type = 'NONE';
BEGIN
OPEN C_TABLE;
FOR cur_row AS C_TABLE DO
EXEC cur_row.SQLTEXT;
END FOR;
END;

You can execute below procedure like this:

CALL convert_column;

Unloading all column table in hana

You can use below procedure for unloading all column tables in Hana.

create procedure unload_all() LANGUAGE SQLSCRIPT AS
CURSOR C_TABLE
FOR SELECT 'UNLOAD “' || TABLE_NAME || '”;' AS SQLTEXT
FROM SYS.TABLES
WHERE SCHEMA_NAME = 'MYSCHEMA' AND TABLE_TYPE = 'COLUMN' and temporary_table_type = 'NONE';
BEGIN
OPEN C_TABLE;
FOR cur_row AS C_TABLE DO
EXEC cur_row.SQLTEXT;
END FOR;
END;

You call this procedure like below:

CALL unload_all;

itab to file with separated by coma, semicolon, etc

data: struct type ref to cl_abap_structdescr,
ls_component type abap_compdescr.
lt_tab  type truxs_t_text_data with header line,
ls_tab(4096),
lv_tab       type string.
lv_text      type c length 255.
field-symbols: <lfs_file>  type any.
loop at lt_itab.
clear: lt_tab,
lv_tab.
loop at struct->components into ls_component.
read table gt_fieldcat into gs_fcat with key fieldname = ls_component-name.
check sy-subrc eq 0.
ASSIGN COMPONENT ls_component-name OF STRUCTURE lt_itab TO <lfs_file>.
check sy-subrc eq 0.
case gs_fcat-datatype.
when 'DATS'.
write <lfs_file> to lv_text MM/DD/YYYY.
when 'QUAN' or 'CURR'.
write <lfs_file> to lv_text.
call function 'CLOI_PUT_SIGN_IN_FRONT'
changing
value = lv_text.
when 'INT4'.
write <lfs_file> to lv_text DECIMALS 0.
call function 'CLOI_PUT_SIGN_IN_FRONT'
changing
value = lv_text.
when others.
write <lfs_file> to lv_text.
endcase.
condense lv_text.
concatenate lt_tab lv_text into lt_tab
separated by lv_tab.
lv_tab = ';'.    "separator
endloop.
append lt_tab.
endloop.

LOWERCASE HTTP SCRAMBLE

REPORT  Z_LOWERCASE_HTTP_SCRAMBLE.
data: conv type ref to cl_abap_conv_out_ce,
buffer type xstring,
x4(4) type x,
y4(4) type x,
x type x,
i type i,
mask(4) type x value '0000003F',
dest(100) type x,
lf type f.


data: stab(64) type x value
'F0ED53B83244F1F876C67959FD4F13A2' &
'C15195EC5483C234774943A27DE26596' &
'5E5398789A17A33CD383A8B829FBDCA5' &
'55D702778413ACDDF9B83116610E6DFA'.
data: sourcelen type i,
key       type i,
source    type string,
destination type c LENGTH 100.
sourcelen = 5.
key = 26101957.
source = 'sifre'.


if sourcelen eq 0. exit. endif.


y4 = key.
x4 = key * 2.
y4 = y4 bit-xor x4.
x4 = key / 32.
y4 = y4 bit-xor x4.
y4 = y4 bit-and mask.


conv = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' ).
call method conv->write( data = source ).
buffer = conv->get_buffer( ).


i = 0.
do sourcelen times.
if sy-index eq 40.
x4 = 1.
endif.
lf = ( key * i * i - i ) mod 256.
x = lf.
x = stab+y4(1) bit-xor x.
dest+i = buffer+i(1) bit-xor x.
i = i + 1.
y4 = y4 + 1.
y4 = y4 bit-and mask.
enddo.


write dest(sourcelen) to destination.
write destination.