How to Display Header with length Greater then 40 CHAR In SALV? - excel

I would like to know is there any way to set Header with 60 char in SALV? Since there is a CHAR limit of 40 when I try using SET_LONG_TEXT method. I am using this SALV to both display and download it as an excel too.
My Prod Code looks like this below.
TRY.
" Call SALV Factory Method
cl_salv_table=>factory(
EXPORTING
list_display = abap_false
IMPORTING
r_salv_table = DATA(lo_salv)
CHANGING
t_table = <fs_global_factor_data> ).
DATA(lo_columns) = lo_salv->get_columns( ).
lo_columns->set_optimize( ).
DATA(lo_col_ref) = lo_columns->get( ).
" Get the Field Description in the table
lr_strucdesc ?= cl_abap_typedescr=>describe_by_data( ls_struct ).
/stl/cl_gf_validations=>at_gf_table_struct = lr_strucdesc->get_ddic_field_list( ).
Here, I am replacing the long text with my own texts with a length of 60 Char from the AT_FIELD_HEADER table.
" Remove Short and Medium texts and Replace long texts from AT_FIELD_HEADER Table
LOOP AT lo_col_ref ASSIGNING FIELD-SYMBOL(<fs_col_ref>).
<fs_col_ref>-r_column->set_short_text( space ).
<fs_col_ref>-r_column->set_medium_text( space ).
<fs_col_ref>-r_column->set_fixed_header_text( lc_char_l ) .
<fs_col_ref>-r_column->set_long_text( SWITCH #( <fs_col_ref>-columnname+0(5) WHEN /stl/cl_gf_validations=>ac_desc_field_prefix THEN /stl/cl_gf_validations=>ac_fd_description
ELSE CONV #( LET line = VALUE /stl/cl_gf_validations=>ty_field_header( /stl/cl_gf_validations=>at_field_header[ fieldname = <fs_col_ref>-columnname ] OPTIONAL )
IN COND #( WHEN line-title IS NOT INITIAL THEN line-title ELSE line-description )
) ) ).
ENDLOOP.
DATA(lv_xml_type) = if_salv_bs_xml=>c_type_xlsx.
DATA(lv_data_in_xstring) = lo_salv->to_xml( xml_type = lv_xml_type ).
CATCH cx_root.
MESSAGE e033(/stl/bw_gf_msg).
ENDTRY.
" Convert XSTRING TO BIN
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lv_data_in_xstring
IMPORTING
output_length = lv_file_size
TABLES
binary_tab = lt_data_in_bin.
Here, GUI_DOWNLOAD is used to download it as an excel file.
" Download the Excel
cl_gui_frontend_services=>gui_download(
EXPORTING
bin_filesize = lv_file_size
filename = lv_fullpath
filetype = lc_filetype_bin
CHANGING
data_tab = lt_data_in_bin
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
not_supported_by_gui = 22
error_no_gui = 23
OTHERS = 24
).
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Also, I am using the same piece of code to display the SALV where header gets truncated to 40 char.

Related

Concatenating a few strings

Do you have any idea about this problem?
Question:
Write and execute an LC-3 assembly program which concatenates two strings. The first string begins at memory address x4000, and the second string begins at memory address x5000. Strings always terminate with a 0.
Example​:Before​ your program executes:
M[x4000] = 5 M[x5000] = 6
M[x4001] = 2 M[x5001] = 1
M[x4002] = 8 M[x5002] = 8
M[x4003] = 4 M[x5003] = 0
M[x4004] = 0
After​ your program executes:
M[x4000] = 5 M[x5000] = 6
M[x4001] = 2 M[x5001] = 1
M[x4002] = 8 M[x5002] = 8
M[x4003] = 4 M[x5003] = 0
M[x4004] = 6 M[x4005] = 1
M[x4006] = 8 M[x4007] = 0
Here's an idea: write a loop to locate the address of the first zero word starting from 0x4000. Once you've found that, write another loop that will copy words from 0x5000 and further to that address, terminating once the zero byte is copied.

How to convert 24 hour format to 12 hour format in groovy [duplicate]

This question already has answers here:
How to convert 24 hr format time in to 12 hr Format?
(16 answers)
Closed 3 years ago.
I'm new to groovy and i want to convert 24 hour format to 12 hour format. What is the code to be used for it? Is there any built-in methods?
I just want groovy code not java one
Kevin's answer is correct, and should get the tick... I only post this as it's slightly shorter
import java.time.*
import static java.time.format.DateTimeFormatter.ofPattern
String time = '13:23:45'
String result = LocalTime.parse(time).format(ofPattern('h:mm:ss a'))
println result
I thought this question is somewhat similar to the How to convert 24 hr format time in to 12 hr Format?. It just that Java and Groovy share a lot of similarities. To point that out, I took Cloud's answer from the mentioned question and converted that to Groovy.
import java.time.LocalTime
import java.time.format.DateTimeFormatter
final String time = "21:49"
String result = LocalTime.parse(time, DateTimeFormatter.ofPattern("HH:mm")).format(DateTimeFormatter.ofPattern("hh:mm a"));
println(result)
If you want to build your own time function you can try to customize the code below.
final String time = "21:49"
final String _24to12( final String input ){
if ( input.indexOf(":") == -1 )
throw ("")
final String []temp = input.split(":")
if ( temp.size() != 2 )
throw ("") // Add your throw code
// This does not support time string with seconds
int h = temp[0] as int // if h or m is not a number then exception
int m = temp[1] as int // java.lang.NumberFormatException will be raised
// that can be cached or just terminate the program
String dn
if ( h < 0 || h > 23 )
throw("") // add your own throw code
// hour can't be less than 0 or larger than 24
if ( m < 0 || m > 59 )
throw("") // add your own throw code
// minutes can't be less than 0 or larger than 60
if ( h == 0 ){
h = 12
dn = "AM"
} else if ( h == 12 ) {
dn = "PM"
} else if ( h > 12 ) {
h = h - 12
dn = "PM"
} else {
dn = "AM"
}
return h.toString() + ":" + m.toString() + " " + dn.toString()
}
println(_24to12(time))

How to loop values of a variable through a nested while loop calling on a function in Python

I have a while loop that calls on a function (def update(i)) and performs the calculation for the required number of times (until the while loop condition is no longer met) in Python3. What I now want to do is put different values of 'i' through the while loop and therefore through the equation 'dv' (shown below). So when the while loop ends I need the whole process to repeat with the next 'i' value. All the i values are in an np.arange array called 'i_es'. I have tried to implement this with the while loop nested inside a for loop as shown below...
import numpy as np
def update(i) :
dv = (e_l - v_s[-1] + i*r_m)/tau_m
v_s.append(v_s[-1] + (dv*dt))
return is_spiked()
def is_spiked() :
if v_s[-1] > v_th:
v_s[-1] = v_r
return True
return False
r_m = 10
tau_m = 10
v_th = -40
e_l = -70
v_r = -70
v_s = [v_r]
spike_count = 0
t = 0
t_total = 1000
dt = 1
i_e_start = 4
i_e_step = 0.1
i_e_final = 5
i_es = np.arange(i_e_start,i_e_final+i_e_step,i_e_step)
for i in i_es :
while t < t_total :
if update(i) :
spike_count += 1
t += dt
print ("Current = ",+ i, " Spike count = ", + spike_count)
However, when I run this I get the following output:
Current = 4.0 Spike count = 71
Current = 4.1 Spike count = 71
Current = 4.2 Spike count = 71
Current = 4.3 Spike count = 71
Current = 4.4 Spike count = 71
Current = 4.5 Spike count = 71
Current = 4.6 Spike count = 71
Current = 4.7 Spike count = 71
Current = 4.8 Spike count = 71
Current = 4.9 Spike count = 71
Current = 5.0 Spike count = 71
I can see that the current ('i') values are increasing as they should each time but the spike count is not changing.. The answer is always from the first value ('i' = 4) run through the loop.
Can anyone help with this?
Thanks in advance.

Explanation of algorithm that get the excel column title

According to this topic:
How to convert a column number (e.g. 127) into an excel column (e.g. AA)
I don't understand what is in algorithm:
here
Could someone explain me, what is happening in a while loop?
It is, in effect, "converting" the column number to base 26, where the "digits" are the letters A..Z.
For example, for column 720:
modulo = (720-1)%26 = 17
columnName = 'R'
dividend = (720-17)/26 = 27
modulo = (27-1)%26 = 0
columnName = A+columnName = AR
dividend = (27-0)/26 = 1
modulo = (1-1)%26 = 0
columnName = A + columnName = AAR
dividend = (1-0)/26 = 0
Resulting in AAR.

Sphinxsearch index min_stemming_len

Here is my sphinx search configuration (sphinxsearch_0.9.9-6_amd64):
index FULL
{
charset_type = utf-8
source = FULL
path = /var/sphinx/data/Full
docinfo = extern
mlock = 0
min_stemming_len = 1
min_prefix_len = 1
min_word_len = 1
html_strip = 1
index_exact_words = 1
}
searchd
{
listen = 192.168.2.3
log = /var/log/sphinxsearch/searchd.log
query_log = /var/log/sphinxsearch/query.log
read_timeout = 3
client_timeout = 60
max_children = 30
pid_file = /var/run/searchd.pid
max_matches = 1000
seamless_rotate = 1
preopen_indexes = 0
unlink_old = 1
mva_updates_pool = 1M
max_packet_size = 8M
max_filters = 256
max_filter_values = 4096
}
I use php as client
$sphinx_client->SetServer('localhost', 9312);
$sphinx_client->SetConnectTimeout(1);
$sphinx_client->SetArrayResult(true);
$sphinx_client->setRankingMode(SPH_RANK_WORDCOUNT);
$sphinx_client->SetMatchMode(SPH_MATCH_EXTENDED2);
if ($mode == 'all') {
$sphinx_client->SetSortMode(SPH_SORT_RELEVANCE, 'category');
} else {
$sphinx_client->setFilter('category', array($this->_filter_category), FALSE);
}
$sphinx_client->SetLimits(0, $this->_limit);
$results = $sphinx_client->Query('"^'.$query.'$"', 'FULL');
for example i have those names in index :
1. Alex
2. Alen
3. George
4. A
5. G
::: When i try to search for simple 1 char string "A" i get Alen / Alex / A and so on.
How can i search based on string length so i can display them in right order like :
A / Alen / Alex ...
I also get "WARNING: index 'FULL': no morphology, index_exact_words=1 has no effect, ignoring"
Best Regards
use an ordinal field ( str2ordinal ) , do your normal search , but modify sort mode : switch to extended mode and use a combination like $sphinx_client->SetSortMode(SPH_SORT_EXTENDED, '#weight desc , myordinal asc');

Resources