SAP Smartforms dynamically change position of certain items - abap

So I got this text of which I can't know the length beforehand because it depends on how many entries there are in an internal table (see below). The table is given to the Smartforms FM in my report. The text itself works fine with a dynamic text variable, but under that text I need a horizontal line. The Line needs to be right beneath the text at all time. So far I only got a line with a fixed position, which does not lead to the result I want.
If it is possible, how can I get the line to change position based on the length of the text? So that it is right under the text at all time, no matter how many lines the text got.
DATA: l_string TYPE string,
lt_stream_lines TYPE STANDARD TABLE OF string.
loop at i_tab.
* reading one line of i_tab into l_string.
APPEND l_string TO lt_stream_lines.
APPEND '' TO lt_stream_lines.
endloop.
CALL FUNCTION 'CONVERT_STREAM_TO_ITF_TEXT'
EXPORTING
stream_lines = lt_stream_lines
lf = 'X'
TABLES
itf_text = gv_text.
* gv_text then has the full text I want to display

You must have a Main Window containing your Text element followed by a dummy Template element for the horizontal line (one empty cell with the top horizontal border in black color and other borders transparent).
Create a Template element via the context menu:
Draw the border (here I exaggerate the proportions "a little bit"!):
Preview result:

Related

How do you detect if a specific string will either fit or take up a second line in a textbox in Crystal Reports/VB.NET/SQL?

So basically I have a textbox with a specific width and I need to know if the string I will put into it will either fit nicely in one line or take a second line. For example: I have
string v = "WERTYUIOSDFGHJKWERTYUISDFGHJKXCVBNSDFGHJ"
and a textbox that's 3000 in width.
At first I tried: if v.length = x then... where x is the length of the string that can fit into the textbox. But I soon found out that strings with mostly 'I' can fit more inside compared to a string of mostly 'M'. And that is where the problem lies. Is there a function that detects if the string is going to take/need a second line?
Another option is to create or use a 3rd-party Crystal Reports UFL (User Function Library). A list of 3rd-party UFLs is maintained by Ken Hamady here.
At least one of these UFLs provides functions that allow Crystal formulas to either:
a. specify as input the text, font name, font size, bold and italics status and get the required width (in pixels or twips), or
b. specify the available width for the text and get the maximum font size to fit, or the number of lines required for a given font size.
The advantage of using a UFL approach is that Crystal supports dynamic property expressions. That means that the result of the function call can dynamically control a property such as font size, height, position, etc.

Add text box at specific location in report base on value

I'm working on a cut list generator but I'm having difficulty on the final report. I'd like to display a rectangle that represents the factory length piece with lines indicating cut points. In each segment I'd like to have the length of the piece shown. Using Report.line I've created the rectangles needed but I'm not sure how to get text in each box. Here is a sample output so far As an example I want the three rectangles for Piece #1 to have 48" in them, probably all the way to the left. Any suggestions? I thought createReportControl might work but I'm not sure that is the correct approach. I'm also thinking about one text box with a monospace font so I can scale the input across the entire width. Any suggestions are appreciated.
Thanks,
Dave
I played around with the monospace font idea. It isn't as pretty as I would like but I'm getting closer.
The issue is that I cannot keep the text in the same spot in each box. There is one line lower on the page that pushes the number almost out the right side of the box.
Sample Output
This code is functional but I'm looking at the cosmetics. I'm inserting spaces between my values using the following function:
Private Function InsertSpaces(CutLen, PieceLen) As String
MaxChar = 50 ' 6 inch 14pt Courier text box
cutchar = Int(CutLen / PieceLen * MaxChar)
Cutcharcount = Len(Str(CutLen))
cutchar = cutchar - Cutcharcount + 1
For i = 1 To cutchar
InsertSpaces = InsertSpaces + " "
Next
End Function
I'm just trying to clean it up. CreateReportControl was giving me a error because I wasn't in design mode. I'm guessing that is because it ran as part of OnFormat of the Detail section.

vb.net I am trying to size a control (label, textbox, richtextbox) so that it is the smallest square that contains a given string

I need to present arbitrary text, which might include line breaks, in a square control with word wrap such that the square is as small as possible but sufficiently large to display the text in its entirety.
This is the closest I've gotten so far:
Load the text into a temporary rich text box, Rich, with BorderStyle = none
I increment the value of size, width=height=size until Rich.ClientRectangle.Width = Rich.Width.
If I could now extract the visual lines one by one I would be done, as I could then save the original string with appropriate line breaks for later display.
Visual lines are not, of course, the same as Rich.Lines array.
Any ideas?
Thank you.

Photoshop Scripting: How to change a certain part of text in a text layer

I'm trying to have text in my document but get the last two characters of the text contents to change size.
For example, I have a text layer in a group and I set the contents to "100ft". I would like to make the last two characters "ft" a different size than the rest of the text.
it's very easy!
1 choose your text layer
2 choose type tool from left side tools
click on your text with type tool selected
select letters that you want to change them sizes
from top panel choose any size you need

Crystal Reports Cutting Off Text in PDF

I found this post on Crystal Reports Cutting Off Text in PDF, but it didn't solve my problem.
I have a Crystal Report that contains a field within a text object (to control line spacing) and has "can grow" selected. When I export the Crystal Report to a PDF there are instances when the text is cut off.
In this example the text is being cut off on the right side, but in some cases, when the text consists of many lines, the bottom part of the last line will be partially cut off.
I am using Crystal Reports that is bundled with Visual Studio 2008. The text area has "can grow" checked, the font is set to Helvetica LT Condensed, bold 14, and the line spacing is set to 0.75 times normal.
Anyone have any thoughts on how can I fix this?
I have run into this as well - Crystal seems a little confused about where the text box borders are. I suggest adding a small right indent to the text box (right click on the text box, select 'Format Object', select the 'Paragraph' tab, and enter small numbers (maybe .2 or so) into the Right text box. This should help with the right margin.
As for the bottom cut-off, there is no margin that you can add. Can you add a line break to the end of your text as it comes from the db? Or, you could try a formula field to add the line break:
{table_name.field_name} + chr(13) + chr(10)
I think I've found out the problem. The bounding subreport width was smaller than the width of the field object. Adjusting it's width fixed the truncation occurring on the right-hand side.
On a side note, text being truncated on the bottom seems to be a result of adjusting the line-spacing too small. if you set the line spacing as a multiple of the original text point size and make it too small, the bottom part of the line is truncated. I changed this to "exact" and entered a specific point size (e.g line spacing of 18 pt. for my 16 pt. text) and this seemed to solve the problem. If the line spacing is too small it seems that Crystal masks off the bottom part of the text.
Right click on the text field
Select Common Tab
In the Horizontal Alignment section I changed it to "Justified".
This adjusted the text to span properly and not cut off prematurely when using Can Grow.
I tried this and it solved this issue.
Try to do following :
Text Object > Right Click > Format Text > Border Tab
Change Line Style : Right/Left/Top/Bottom as single and change color to White.
I experienced this problem when I updated a Stored procedure. I changed the Description field that I was pulling onto the report from a VARCHAR(100) to a VARCHAR(150) inline with a requested change. The Crystal report in preview mode had stored old limit of 100 characters and was truncating the label. This was rectified when I verified the database again.
Database Tab -> Verify Database
I too discovered this too. Only happened in HTML view. I did a few things which for 3 blocks I needed to do different and tried numerous scenarios to choose the best to go with.
- Format text from left justufied to justified
- Grip the right edge of the text box and pulled it in a tick from the right margin
- Switched the font from Times New Roman to another (wierd)
- Exporting from BI LP as a CR RPT and exported from the CR 2013 client to PDF
- Change font size - We had an "and / or" midline and changed it to "and/or"
We went with the justified alignment since it was close to a full line and didn't look different than original.
Lots of wierd workarounds that rectified it. To me, it's indicating a system upgrade glitch in the report.
Hope what I found helps others.
If you tried all the methods and still not working, you can try the following:
Local StringVar inString := 'Your text string here.......';
Local NumberVar strLen := Length (inString);
Local StringVar result := "";
Local NumberVar maxLen := 45; // adjust the length of text per line
Local NumberVar idx := 0;
Local NumberVar proceed := 0;
While strLen > maxLen Do
(
proceed := 1;
idx := maxLen;
While (mid(inString,idx,1) <> " " and idx > 1) Do
(
idx := idx -1;
);
if (idx = 1) then
result := result + mid(inString,1,maxlen) + chr(10)
else
(
result := result + mid(inString, 1, idx-1)+ chr(10);
strLen := strLen-idx;
inString := mid(inString, idx+1, strLen)
)
);
if proceed = 1 then
(
result := result + inString
)
else
(
result := inString
);
result
In one environment with Crystal Reports it was a help for us to set the registry key: ForceLargerFonts = 0
How to find?
For 64 bit version of MS Windows:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\SAP BusinessObjects\Suite XI 4.0\Crystal Reports\Export\PDF
For 32 bit version of MS Windows:
HKEY_LOCAL_MACHINE\SOFTWARE\SAP BusinessObjects\Suite XI 4.0\Crystal Reports\Export\PDF
Please see also the following solution at
https://apps.support.sap.com/sap/support/knowledge/public/en/0001835763
This is a difficult problem that you have to attack from 3 different fronts:
Software Hot Fix
Default Printer
Form Authoring
Software Hot Fix: You'll need to download the CRRuntime that includes Hot Fix 20. This Hot Fix addresses truncation problems when making a PDF. You can find it at http://downloads.businessobjects.com/akdlm/crnetruntime/clickonce/CRRuntime_64bit_13_0_20.msi
Default Printer: The printer you use when authoring a report must match a printer where you are rendering a report. On our servers, there are no printers installed except the Microsoft XPS Document Writer. Be sure to select that as you default printer when writing the report.
Form Authoring: When you add a database field to your report, don't drag it from the field explorer onto the design surface. First insert a text object onto the design surface. When you've positioned and resized the Text Object the way you like it, drag the database field onto the Text Object. You'll see the name of the database item in curly braces appear in the Text Object. For whatever reason, the database field will wrap better when it is enclosed by a Text Object.
This got me literally stressed for a whole night!!
What worked for me was this:
if you are using crystal reports with dataset (linked to a dataset),most likely you changed the length of the field in the database. so if the length was 10 and you adjust to 20 for instance, no matter what you do, the report is reading the "Old" dataset with the field of length 10 characters and truncating it at 10 (I don't know why it did that)...believe it or not I just copied the query from my "Old" dataset,created a new dataset and VOILA!!! it worked like charm...