Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Offset Problem

omar_saber
Explorer
0 Kudos
266

Hello,

I am a beginner in ABAP and I want for guideness

I have an error say that teh total of the offset (68) and the length (2) was greater than the current length of the string (69) however.

so I am using this line of code DATA(lv_2bytes) = ls_struc1-data+lv_first_byte_of_row(2).

when I replace the (2) with (1) it works but I want to print 2 digits of the hex number so any suggestion please?

thank you in advance.

1 REPLY 1

yogananda
Product and Topic Expert
Product and Topic Expert
0 Kudos
218

omar.saber

You can use the following code to print 2 digits of a hex number in ABAP:

DATA(lv_2bytes) = ls_struc1-data+lv_first_byte_of_row(2).
DATA(lv_hex) = CONV string( lv_2bytes ).
DATA(lv_hex_2digits) = COND #( WHEN strlen( lv_hex ) EQ 1 THEN '0' && lv_hex ELSE lv_hex ).

This code will convert the value of lv_2bytes to a string and then check if the length of the string is equal to 1. If it is, it will add a ‘0’ in front of the string. Otherwise, it will return the original string.

I hope this helps! Let me know if you have any other questions.