Skip to Content
author's profile photo Former Member
Former Member

Set bit in a xString ?

Hi,

I would like to store bits in a xstring. Notice that the xstring has a variable length. The length can not be predefined.

To set the bit "1" at position "100" for example, I wrote the following code :

DATA : lw_x TYPE xstring.

set bit 100 of lw_x.

It does not work :after execution, my xstring has a length "0" and the 100th bit is not set.

Could you please advise ?

Regards,

G.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jun 14, 2012 at 09:58 AM

    Hi,

    DATA lw_x(200) TYPE x.

    set bit 100 of lw_x.

    Then you can assign that to the XSTRING variable.

    Not tested it though.

    Please check.

    Thanks,

    Shambu

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Thanks Shambu for your anwer. Your solution works but it does not match my need :

      I'd like to avoid to initiate my variables with a "Max fixed size" (I will deal with huge amount of data and I would like my program to be as performant as possible in term of memory comsumption).

      In your suggestion, I allocate 200 bits in memory but only the first 100 bits are relevant.

      Regards,

      G.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.